From: Christian Date: 2007-09-26T15:57:30+09:00 Subject: Re: merge two arrays into a hash irb(main):001:0> key = [ "1", "2", "3"] => ["1", "2", "3"] irb(main):002:0> value = [ "a", "b" ] => ["a", "b"] irb(main):003:0> myhash = {} => {} irb(main):004:0> key.each_with_index {|k,i|myhash[k] = value[i]} => ["1", "2", "3"] irb(main):005:0> myhash => {"1"=>"a", "2"=>"b", "3"=>nil} On 9/26/07, Jan Ask wrote: > Hi all, > > I have looked at some of the answers in the forum, but they do not seem > to fit. I want to merge two array into a hash like so: > > key = [ "1", "2", "3"] > value = [ "a", "b" ] > > into: > > myhash = {'1' => 'a' , '2' => 'b' , '3' => ''} > > Can this be done without creating new classes and methods? > > Thanks a lot > -- > Posted via http://www.ruby-forum.com/. > > -- "Every child has many wishes. Some include a wallet, two chicks and a cigar, but that's another story."