From: "Jesús Gabriel y Galán" Date: 2012-09-25T18:48:29+09:00 Subject: Re: inject problem On Tue, Sep 25, 2012 at 11:31 AM, Jan E. wrote: > Hi, > > Using "inject" really isn't a good choice here. If at all, I'd use > "each_with_object" to build up the hash. My preferred solution: count = [1,2,1,1] h = Hash.new(0) count.each {|el| h[el] += 1} p h #=> {1=>3, 2=>1} Jesus.