Bob Nadler, Jr. Logo

Turn a Ruby Array into a Hash

I always forget the syntax for this:

ary = [:a, 1, :b, 2, :c, 3]
Hash[*ary] # => { :a => 1, :b => 2, :c => 3 }


Email list
Image by husin.sani

No spam, ever. Unsubscribe at any time.