From: "Jesús Gabriel y Galán" Date: 2010-03-25T20:33:07+09:00 Subject: Re: How to create mutiple hash dynamicaly On Thu, Mar 25, 2010 at 12:23 PM, Nike Mike wrote: > Lee Jarvis wrote: >> On Mar 25, 10:34�am, Nike Mike wrote: >>> Hi i am having two arrays and i have append into a hash like this.Please >>> help me. >>> >>> {:name=>"Databases",:url=>"http://www.examplw.com"}, >>> {:name=>"Network management",:url=>"http://www.examplw.com"}, >>> {:name=>"Security",:url=>"http://www.examplw.com"}, >>> {:name=>"Service",:url=>"http://www.examplw.com"} >>> {:name=>"Storage",:url=>"http://www.examplw.com/"} >>> -- >>> Posted viahttp://www.ruby-forum.com/. >> >> You need to provide more information before anyone can help you. Your >> intentions aren't clear from this message. What exactly are you trying >> to do? >> >> Regards, >> Lee > > How to create mutiple hash like this > > [{:a=>'1',:b=>'10'}{:a=>'11',:b=>'101'}] It would be clearer if you specified with a code example the input data and the expected output (btw, the above is not correct syntax). But I'll take a stab: irb(main):001:0> first_array = ["Databases", "Network Management", "Security"] => ["Databases", "Network Management", "Security"] irb(main):002:0> second_array = ["http://databases", "http://network", "http://security"] => ["http://databases", "http://network", "http://security"] irb(main):004:0> first_array.zip(second_array).inject([]) {|result, (k,v)| result << {k => v}; result} => [{"Databases"=>"http://databases"}, {"Network Management"=>"http://network"}, {"Security"=>"http://security"}] Is that what you want? Jesus.