Method: Array#to_mash

Defined in:
lib/extlib/array.rb

#to_mashMash

Transforms an Array of key/value pairs into a Mash

This is a better idiom than using Mash in Ruby 1.8.6 because it is not possible to limit the flattening to a single level.

Returns:

  • (Mash)

    A Hash where each entry in the Array is turned into a key/value



33
34
35
36
37
# File 'lib/extlib/array.rb', line 33

def to_mash
  m = Mash.new
  each { |k,v| m[k] = v }
  m
end