In Ruby, given an array in one of the following forms...
[apple, 1, banana, 2] [[apple, 1], [banana, 2]]
...what is the best way to convert
Update
Ruby 2.1.0 is released today. And I comes with Array#to_h (release notes and ruby-doc), which solves the issue of converting an Array to a Hash.
Array#to_h
Array
Hash
Ruby docs example:
[[:foo, :bar], [1, 2]].to_h # => {:foo => :bar, 1 => 2}