From: Jimmy Kofler Date: 2008-05-08T05:44:17+09:00 Subject: Re: hash adding values > Tim Wolak wrote: > > I worked with your code and its giving me the same thing I had before, > below is the output of the script. What I need to do is for example is > the account number 740 is to store it as key 740 and the value is the > sum of the balances listed. So where there is the account number listed > more than once it uses that account number and balance and moves on to > the next line and if that account number is not in the has it puts a new > account number with its balance. Hope this help make a little more > sense of what I'm trying to do. > > {"700"=>[2876.86]} > {"701"=>[654.18]} > ... Could you use Hash#collate (together with an Array#sum method) for this? http://snippets.dzone.com/posts/show/4930 Cheers, j.k. -- Posted via http://www.ruby-forum.com/.