D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Range
/
Filename :
min-i.ri
back
Copy
U:RDoc::AnyMethod[iI"min:ETI"Range#min;TF:publico:RDoc::Markup::Document:@parts[&o:RDoc::Markup::Paragraph; [I"*Returns the minimum value in +self+, ;TI"@using method <tt>#<=></tt> or a given block for comparison.;To:RDoc::Markup::BlankLine o; ; [I"*With no argument and no block given, ;TI"2returns the minimum-valued element of +self+.;T@o:RDoc::Markup::Verbatim; [I"(1..4).min # => 1 ;TI"('a'..'d').min # => "a" ;TI"(-4..-1).min # => -4 ;T:@format0o; ; [I"GWith non-negative integer argument +n+ given, and no block given, ;TI"Creturns the +n+ minimum-valued elements of +self+ in an array:;T@o;; [ I"#(1..4).min(2) # => [1, 2] ;TI"'('a'..'d').min(2) # => ["a", "b"] ;TI"%(-4..-1).min(2) # => [-4, -3] ;TI")(1..4).min(50) # => [1, 2, 3, 4] ;T; 0o; ; [I"'If a block is given, it is called:;T@o:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0; [o; ; [I"1First, with the first two element of +self+.;To;;0; [o; ; [I"VThen, sequentially, with the so-far minimum value and the next element of +self+.;T@o; ; [I"To illustrate:;T@o;; [I"3(1..4).min {|a, b| p [a, b]; a <=> b } # => 1 ;T; 0o; ; [I"Output:;T@o;; [I"[2, 1] ;TI"[3, 1] ;TI"[4, 1] ;T; 0o; ; [I")With no argument and a block given, ;TI"<returns the return value of the last call to the block:;T@o;; [I",(1..4).min {|a, b| -(a <=> b) } # => 4 ;T; 0o; ; [I"FWith non-negative integer argument +n+ given, and a block given, ;TI"Nreturns the return values of the last +n+ calls to the block in an array:;T@o;; [I"5(1..4).min(2) {|a, b| -(a <=> b) } # => [4, 3] ;TI";(1..4).min(50) {|a, b| -(a <=> b) } # => [4, 3, 2, 1] ;T; 0o; ; [I"+Returns an empty array if +n+ is zero:;T@o;; [I"0(1..4).min(0) # => [] ;TI"0(1..4).min(0) {|a, b| -(a <=> b) } # => [] ;T; 0o; ; [I"(Returns +nil+ or an empty array if:;T@o;;;;[o;;0; [o; ; [I"?The begin value of the range is larger than the end value:;T@o;; [ I"1(4..1).min # => nil ;TI"0(4..1).min(2) # => [] ;TI"1(4..1).min {|a, b| -(a <=> b) } # => nil ;TI"0(4..1).min(2) {|a, b| -(a <=> b) } # => [] ;T; 0o;;0; [o; ; [I"EThe begin value of an exclusive range is equal to the end value:;T@o;; [ I"3(1...1).min # => nil ;TI"2(1...1).min(2) # => [] ;TI"3(1...1).min {|a, b| -(a <=> b) } # => nil ;TI"2(1...1).min(2) {|a, b| -(a <=> b) } # => [] ;T; 0o; ; [I"#Raises an exception if either:;T@o;;;;[o;;0; [o; ; [I"1+self+ is a beginless range: <tt>(..4)</tt>.;To;;0; [o; ; [I"5A block is given and +self+ is an endless range.;T@o; ; [I"&Related: Range#max, Range#minmax.;T: @fileI"range.c;T:0@omit_headings_from_table_of_contents_below0I"]min -> object min(n) -> array min {|a, b| ... } -> object min(n) {|a, b| ... } -> array ;T0[ I"(*args);T@~FI" Range;TcRDoc::NormalClass00