From: "ara.t.howard" Date: 2007-10-31T06:48:14+09:00 Subject: Re: better way to accumulate totals On Oct 30, 2007, at 3:40 PM, Joel VanderWerf wrote: > This works... > > count = Hash.new{|h,k| h[k] = Hash.new{|h1,k1| h1[k1] = 0}} > => {} > count[:foo][1] += 1 > => 1 > count[:foo][1] += 1 > => 2 > count[:foo][1] += 1 > => 3 oh yeah, of course ;-) i'm in the habbit of using 'update' from 'inject' where is saves you having to return the hash itself... shorter is better always. cheers. a @ http://codeforpeople.com/ -- it is not enough to be compassionate. you must act. h.h. the 14th dalai lama