Converts fix
to a Float
.
Returns an array of arrays that describe the rows of the matrix.
Overrides Object#to_s
Returns the elements of the vector in an array.
Overrides Object#to_s
Returns option summary list.
Returns option summary list.
Returns the array of matches.
m = /(.)(.)(\d+)(\d)/.match("THX1138.") m.to_a #=> ["HX1138", "H", "X", "113", "8"]
Because to_a
is called when expanding *
variable, there’s a useful assignment shortcut for extracting matched fields. This is slightly slower than accessing the fields directly (as an intermediate array is generated).
all,f1,f2,f3 = * /(.)(.)(\d+)(\d)/.match("THX1138.") all #=> "HX1138" f1 #=> "H" f2 #=> "X" f3 #=> "113"
Returns the entire matched string.
m = /(.)(.)(\d+)(\d)/.match("THX1138.") m.to_s #=> "HX1138"
Convert int
to a BigDecimal
and return it.
require 'bigdecimal' require 'bigdecimal/util' 42.to_d # => #<BigDecimal:1008ef070,'0.42E2',9(36)>
As int
is already an Integer
, all these methods simply return the receiver.
Returns the value as a rational.
1.to_r #=> (1/1) (1<<64).to_r #=> (18446744073709551616/1)
Converts the set to an array. The order of elements is uncertain.
The string representation of true
is “true”.
‘nuf said…
Returns the name of the underlying method.
"cat".method(:count).inspect #=> "#<Method: String#count>"
Returns the name of the underlying method.
"cat".method(:count).inspect #=> "#<Method: String#count>"
Returns formatted message with the inspected tag.
Returns an array containing the items in enum.
(1..7).to_a #=> [1, 2, 3, 4, 5, 6, 7] { 'a'=>1, 'b'=>2, 'c'=>3 }.to_a #=> [["a", 1], ["b", 2], ["c", 3]] require 'prime' Prime.entries 10 #=> [2, 3, 5, 7]
Returns the result of interpreting enum as a list of [key, value]
pairs.
%i[hello world].each_with_index.to_h # => {:hello => 0, :world => 1}
Returns self
.
Invokes the child class’s to_i
method to convert num
to an integer.
1.0.class => Float 1.0.to_int.class => Fixnum 1.0.to_i.class => Fixnum