Module: ArrayToHash

Included in:
Array
Defined in:
lib/support/core_ext.rb

Instance Method Summary collapse

Instance Method Details

#to_hObject



27
28
29
30
31
32
33
# File 'lib/support/core_ext.rb', line 27

def to_h
  if RUBY_VERSION >= '1.8.7'
    Hash[self]
  else
    inject({}) { |h, a| h[a.first] = a.last; h }
  end
end