Hash[ key, value, ... ] â new_hash
Hash[ [ [key, value], ... ] ] â new_hash
Hash[ object ] â new_hash
Hash[ [ [key, value], ... ] ] â new_hash
Hash[ object ] â new_hash
Class Public methods
Creates a new hash populated with the given objects. Equivalent to the
literal { key => value, ... }
. In the
first form, keys and values occur in pairs, so there must be an even number
of arguments. The second and third form take a single argument which is
either an array of key-value pairs or an object convertible to a hash.
Hash["a", 100, "b", 200] #=> {"a"=>100, "b"=>200} Hash[ [ ["a", 100], ["b", 200] ] ] #=> {"a"=>100, "b"=>200} Hash["a" => 100, "b" => 200] #=> {"a"=>100, "b"=>200}
Please login to continue.