From: "Jesús Gabriel y Galán" Date: 2008-06-04T20:12:32+09:00 Subject: Re: Mering an array of hashes On Wed, Jun 4, 2008 at 12:58 PM, Luke Grimstrup wrote: > I have two arrays of hashes and I would like to merge them. > > One array has the array of: > {:id, :name} > > The other, an array of: > {:name, :other_attributes*} > > I've been raking my brains for hours on this one. Is there anyone who > can suggest the best way to merge these two arrays so that I can get the > resulting array of: > {:id. :name, :other_attributes} Is this what you are after? Not sure if I understood your description correctly (an example of input and expected output would help): irb(main):007:0> require 'generator' irb(main):007:0> a = [{:id => 1}, {:id => 2}] irb(main):007:0> b = [{:name => "a"}, {:name => "b"}] irb(main):007:0> s = SyncEnumerator.new a,b irb(main):007:0> s.map{|a,b| a.merge(b)} => [{:name=>"a", :id=>1}, {:name=>"b", :id=>2}] Hope this helps, Jesus.