From: Robert Dober Date: 2007-03-13T11:43:06+09:00 Subject: Re: non-destructive merging of hashes in array On 3/13/07, Mushfeq Khan wrote: > How's this: > > hashes.inject({}) {|result, hash| result.merge(hash) {|k, e, v| (result[k] > || 0) + v}} > > or similarly: > > hashes.inject(Hash.new {|h, k| 0}) {|result, hash| result.merge(hash) {|k, > e, v| result[k] + v}} I bow to superior technique, the merge block form is particularly nice. > > Mushfeq. > Robert -- We have not succeeded in answering all of our questions. In fact, in some ways, we are more confused than ever. But we feel we are confused on a higher level and about more important things. -Anonymous