Method: Array#to_h
- Defined in:
- lib/core/facets/array/to_h.rb
#to_h ⇒ Object
Convert an associative array to a Hash.
Examples
[[:a, 1], [:b, 2]].to_h
#=> {:a=>1, :b=>2}
Returns [Hash].
12 13 14 15 16 |
# File 'lib/core/facets/array/to_h.rb', line 12 def to_h h = {} each{ |(k,v)| h[k] = v } h end |