From: "David A. Black" Date: 2007-09-26T17:09:09+09:00 Subject: Re: merge two arrays into a hash Hi -- On Wed, 26 Sep 2007, Daniel Sheppard wrote: >> key = [ "1", "2", "3"] >> value = [ "a", "b" ] >> >> into: >> >> myhash = {'1' => 'a' , '2' => 'b' , '3' => ''} > > For the special case where key and value do not contain arrays: > > Hash[*key.zip(value).flatten] And in 1.9 you can do: flatten(1) David -- Upcoming training from Ruby Power and Light, LLC: * Intro to Ruby on Rails, Edison, NJ, October 23-26 * Advancing with Rails, Edison, NJ, November 6-9 Both taught by David A. Black. See http://www.rubypal.com for more info!