tags:

views:

47

answers:

1

I have two arrays

a = [:foo, :bar, :baz, :bof]

and

b = ["hello", "world", 1, 2]

I want

{:foo => "hello", :bar => "world", :baz => 1, :bof => 2}

Any way to do this?

+8  A: 
h = Hash[a.zip b] # => {:baz=>1, :bof=>2, :bar=>"world", :foo=>"hello"}

...damn, I love Ruby.

jtbandes
Genius! thank you :)
macek