D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Enumerable
/
Filename :
minmax-i.ri
back
Copy
U:RDoc::AnyMethod[iI"minmax:ETI"Enumerable#minmax;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"KReturns a 2-element array containing the minimum and maximum elements ;TI"%according to a given criterion. ;TI"IThe ordering of equal elements is indeterminate and may be unstable.;To:RDoc::Markup::BlankLine o; ; [I"NWith no argument and no block, returns the minimum and maximum elements, ;TI"Ausing the elements' own method <tt>#<=></tt> for comparison:;T@o:RDoc::Markup::Verbatim; [ I"1(1..4).minmax # => [1, 4] ;TI"3(-4..-1).minmax # => [-4, -1] ;TI"5%w[d c b a].minmax # => ["a", "d"] ;TI"A{foo: 0, bar: 1, baz: 2}.minmax # => [[:bar, 1], [:foo, 0]] ;TI"5[].minmax # => [nil, nil] ;T:@format0o; ; [I"BWith a block given, returns the minimum and maximum elements ;TI" as determined by the block:;T@o;; [ I"M%w[xxx x xxxx xx].minmax {|a, b| a.size <=> b.size } # => ["x", "xxxx"] ;TI""h = {foo: 0, bar: 1, baz: 2} ;TI"6h.minmax {|pair1, pair2| pair1[1] <=> pair2[1] } ;TI"!# => [[:foo, 0], [:baz, 2]] ;TI"J[].minmax {|a, b| a <=> b } # => [nil, nil] ;T; 0o; ; [I"%Related: #min, #max, #minmax_by.;T: @fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I"[minmax -> [minimum, maximum] minmax {|a, b| ... } -> [minimum, maximum] ;T0[ I"();T@*FI"Enumerable;TcRDoc::NormalModule00