skibud2 pisze:
> Hey Guys,
> 
> I want to convert an array like the following to a hash. Below is my
> current code (I am assuming there is a better way).
> 
> Thanks
> 
> ["foo", "bar", "foo1", "bar1","foo2", "bar2"]   convert to
> {"foo"=>"bar", "foo1"=>"bar1","foo2"=>"bar2"}
> 

given:
a = ["foo", "bar", "foo1", "bar1","foo2", "bar2"]

puts Hash[*a]

or:

require 'enumerator'
h = {}
a.each_slice(2){|k,v|h[k]=v}
puts h


lopex