From: Robert Klemme Date: 2011-03-23T02:09:51+09:00 Subject: Re: summing values in a hash? On Tue, Mar 22, 2011 at 4:31 PM, Robert Dober wrote: > On Tue, Mar 22, 2011 at 4:08 PM, Robert Klemme > wrote: >  jruby -e 'p( {:a=>42}.inject(0){|a,b|a+b})' > TypeError: Array can't be coerced into Fixnum >         + at org/jruby/RubyFixnum.java:333 >  __file__ at -e:1 >      each at org/jruby/RubyHash.java:1167 >    inject at org/jruby/RubyEnumerable.java:816 >    (root) at -e:1 > > I recon you where coming from Hash#values, however on applying the > code to an empy hash, where it works of course the reader could be > missled My code explicitly included #values so it would not be affected by the error you posted - even for non empty Hash. Please read what I wrote. Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/