Hi all,

What's the easiest (i.e. a one liner) for creating a hash based on an array?
I just wanted to convert an array to a hash, using the even numbered indices
as the key and the odd numbered indices as the value for that key.

array = ['one', 1, 'two', 2, 'three', 3]

I tried some things like "hash = {array}" or "hash = {array.each}" but that
didn't work.

I came up with this:

hash = {}
array.each{ |i| hash[i] = array.delete(array.index(i)+1) }.clear

....though this still leaves a reference to the array object around (can I
explicitly remove it?)

Mainly I'm asking because I'm reading a series of lines in a file that
consist of six words that I want to turn into key-value pairs, though the
words may not be in the same order (that's why I can't just hard-code the
indices).

Thanks in advance for any help.

Regards,

Dan