D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Enumerable
/
Filename :
min-i.ri
back
Copy
U:RDoc::AnyMethod[iI"min:ETI"Enumerable#min;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"RReturns the element with the minimum element according to a given criterion. ;TI"IThe ordering of equal elements is indeterminate and may be unstable.;To:RDoc::Markup::BlankLine o; ; [I"AWith no argument and no block, returns the minimum element, ;TI"Ausing the elements' own method <tt>#<=></tt> for comparison:;T@o:RDoc::Markup::Verbatim; [ I")(1..4).min # => 1 ;TI"*(-4..-1).min # => -4 ;TI"+%w[d c b a].min # => "a" ;TI"1{foo: 0, bar: 1, baz: 2}.min # => [:bar, 1] ;TI"+[].min # => nil ;T:@format0o; ; [I"=With positive integer argument +n+ given, and no block, ;TI"Kreturns an array containing the first +n+ minimum elements that exist:;T@o;; [ I"1(1..4).min(2) # => [1, 2] ;TI"3(-4..-1).min(2) # => [-4, -3] ;TI"5%w[d c b a].min(2) # => ["a", "b"] ;TI"A{foo: 0, bar: 1, baz: 2}.min(2) # => [[:bar, 1], [:baz, 2]] ;TI"-[].min(2) # => [] ;T; 0o; ; [I"DWith a block given, the block determines the minimum elements. ;TI"HThe block is called with two elements +a+ and +b+, and must return:;T@o:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0; [o; ; [I"*A negative integer if <tt>a < b</tt>.;To;;0; [o; ; [I"Zero if <tt>a == b</tt>.;To;;0; [o; ; [I"*A positive integer if <tt>a > b</tt>.;T@o; ; [I")With a block given and no argument, ;TI"<returns the minimum element as determined by the block:;T@o;; [ I"@%w[xxx x xxxx xx].min {|a, b| a.size <=> b.size } # => "x" ;TI""h = {foo: 0, bar: 1, baz: 2} ;TI"Bh.min {|pair1, pair2| pair1[1] <=> pair2[1] } # => [:foo, 0] ;TI"@[].min {|a, b| a <=> b } # => nil ;T; 0o; ; [I"AWith a block given and positive integer argument +n+ given, ;TI"Lreturns an array containing the first +n+ minimum elements that exist, ;TI" as determined by the block.;T@o;; [ I"K%w[xxx x xxxx xx].min(2) {|a, b| a.size <=> b.size } # => ["x", "xx"] ;TI""h = {foo: 0, bar: 1, baz: 2} ;TI"6h.min(2) {|pair1, pair2| pair1[1] <=> pair2[1] } ;TI"!# => [[:foo, 0], [:bar, 1]] ;TI"B[].min(2) {|a, b| a <=> b } # => [] ;T; 0o; ; [I"%Related: #min_by, #minmax, #max.;T: @fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I"|min -> element min(n) -> array min {|a, b| ... } -> element min(n) {|a, b| ... } -> array ;T0[ I"(*args);T@TFI"Enumerable;TcRDoc::NormalModule00