Module: Enumerable
- Included in:
- ObjectSpace
- Defined in:
- lib/extra_lib/core_ext/enumerable.rb
Instance Method Summary collapse
-
#to_hash ⇒ Object
Get a hash representation of an array.
Instance Method Details
#to_hash ⇒ Object
Get a hash representation of an array. The number of flattened array elements has to be even in order for this to work.
Example: [:foo, :bar, :baz, :qux].to_hash #=> {:foo => :bar, :baz => :qux}
Returns: Hash object
9 10 11 |
# File 'lib/extra_lib/core_ext/enumerable.rb', line 9 def to_hash Hash[*to_a.flatten] end |