From: 7stud -- Date: 2009-04-30T17:37:42+09:00 Subject: Re: Advanced array merging Jack Bauer wrote: > Hi everyone, > > I'm looking for the fastest way (or the version with the least code!) to > consolidate a couple of arrays. > Those two requirements are often at odds with each other. For instance, "inject" and "fastest" should not be used in the same sentence. result = [] arr.each do |sub_arr| counter_total = 0 sub_arr.each do |obj| counter_total += obj.counter end sub_arr[0].counter = counter_total result << sub_arr[0] #or result << [sub_arr[0]] end -- Posted via http://www.ruby-forum.com/.