Module: Enumerable

Included in:
ObjectSpace
Defined in:
lib/extra_lib/core_ext/enumerable.rb

Instance Method Summary collapse

Instance Method Details

#to_hashObject

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