From: Luke Grimstrup Date: 2008-06-04T21:13:02+09:00 Subject: Re: Mering an array of hashes Actually, complete code: a1 = [{:name=>"File1.rar", :id=>"a3d80425a51a3a4cb2d7a3201439ef6cc3af5874"}, {:name=>"File2.avi", :id=>"58a658047ccb7333eb812da02dca9d84c1db2b41"}, {:name=>"File3.avi", :id=>"944f6a7c50a4a5cff0c28cb0f9158b16580b0310"}] a2 = [{:name=>"File2.avi", :other_attributes =>"(350 MiB) - 2.85% downloading at 0.00 B/s (UL at 0.00 B/s), stalled [error (tracker-warning) - Tracker hasn't responded yet. Retrying...]"}, {:name=>"File1.rar", :other_attributes=>" (26.6 MiB) - 100% seeding at 0.00 B/s [0.23]"}, {:name=>"File3.avi", :other_attributes=>"(35.5 MiB) - 0.86% downloading at 0.00 B/s (UL at 0.00 B/s), stalled"}] a2.each{|d| d.merge!(a1.select{|e| e[:name] == d[:name]}.first)} Luke Grimstrup wrote: > Ah, that does work too! > > A friend of mine told me what I "should" be doing to get it working, but > left the exercise of the coding it up to me. > > Here's the magic: > hash_b.each{|d| d.merge!(hash_a.select{|e| e[:name] == d[:name]}.first)} -- Posted via http://www.ruby-forum.com/.