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
You can also simply convert a 2D array into hash using:
1.9.3p362 :005 > a= [[1,2],[3,4]] => [[1, 2], [3, 4]] 1.9.3p362 :006 > h = Hash[a] => {1=>2, 3=>4}