This is similar to PrettyPrint::format
but the result has no breaks.
maxwidth
, newline
and genspace
are ignored.
The invocation of breakable
in the block doesn’t break a line and is treated as just an invocation of text
.
Returns the object in ary with the maximum value. The first form assumes all objects implement Comparable
; the second uses the block to return a <=> b.
ary = %w(albatross dog horse) ary.max #=> "horse" ary.max {|a, b| a.length <=> b.length} #=> "albatross"
If the n
argument is given, maximum n
elements are returned as an array.
ary = %w[albatross dog horse] ary.max(2) #=> ["horse", "dog"] ary.max(2) {|a, b| a.length <=> b.length } #=> ["albatross", "horse"]
Returns the object in ary with the minimum value. The first form assumes all objects implement Comparable
; the second uses the block to return a <=> b.
ary = %w(albatross dog horse) ary.min #=> "albatross" ary.min {|a, b| a.length <=> b.length} #=> "dog"
If the n
argument is given, minimum n
elements are returned as an array.
ary = %w[albatross dog horse] ary.min(2) #=> ["albatross", "dog"] ary.min(2) {|a, b| a.length <=> b.length } #=> ["dog", "horse"]
Returns the remainder after dividing int
by numeric
.
x.remainder(y)
means x-y*(x/y).truncate
.
5.remainder(3) #=> 2 -5.remainder(3) #=> -2 5.remainder(-3) #=> 2 -5.remainder(-3) #=> -2 5.remainder(1.5) #=> 0.5
See Numeric#divmod
.
Returns 1.
Returns the imaginary part.
Complex(7).imaginary #=> 0 Complex(9, -4).imaginary #=> -4
Returns the denominator (lcm of both denominator - real and imag).
See numerator.
Returns 1
if cmp
‘s real or imaginary part is an infinite number, otherwise returns nil
.
For example: (1+1i).infinite? #=> nil (Float::INFINITY + 1i).infinite? #=> 1