Converts hsh to a nested array of [
key, value ]
arrays.
h = { "c" => 300, "a" => 100, "d" => 400, "c" => 300 } h.to_a #=> [["c", 300], ["a", 100], ["d", 400]]
Return the contents of this hash as a string.
h = { "c" => 300, "a" => 100, "d" => 400, "c" => 300 } h.to_s #=> "{\"c\"=>300, \"a\"=>100, \"d\"=>400}"
Converts the environment variables into an array of names and value arrays.
ENV.to_a # => [["TERM", "xterm-color"], ["SHELL", "/bin/bash"], ...]
Returns “ENV”
Creates a hash with a copy of the environment variables.
Returns “ARGF”.
Returns an integer representing the numeric file descriptor for the current file. Raises an ArgumentError
if there isn’t a current file.
ARGF.fileno #=> 3
Reads ARGF
‘s current file in its entirety, returning an Array
of its lines, one line per element. Lines are assumed to be separated by sep.
lines = ARGF.readlines lines[0] #=> "This is line one\n"
Returns the integer representation of the ipaddr.
Returns a string containing the IP address representation.
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 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"
Converts the set to an array. The order of elements is uncertain.
Set[1, 2].to_a #=> [1, 2] Set[1, 'c', :s].to_a #=> [1, "c", :s]
The string representation of true
is “true”.
The string representation of false
is “false”.
Returns a human-readable description of the underlying method.
"cat".method(:count).inspect #=> "#<Method: String#count>" (1..3).method(:map).inspect #=> "#<Method: Range(Enumerable)#map>"
In the latter case, the method description includes the “owner” of the original method (Enumerable
module, which is included into Range
).
Returns a human-readable description of the underlying method.
"cat".method(:count).inspect #=> "#<Method: String#count>" (1..3).method(:map).inspect #=> "#<Method: Range(Enumerable)#map>"
In the latter case, the method description includes the “owner” of the original method (Enumerable
module, which is included into Range
).