From: "Jan E." Date: 2012-09-25T23:31:12+09:00 Subject: Re: inject problem The first parameter of the "inject" block is always the intermediate result used for the aggregation. And the second is the current element. For example: # calculate sum of 1, 2, ..., 10 (in an inefficient way) sum = (1..10).inject do |intermediate_sum, integer| intermediate_sum + integer end Or in your case: count = [1, 2, 1, 1] hash = count.inject({}) do |intermediate_hash, number| intermediate_hash[number] += 1 rescue intermediate_hash[number] = 1 intermediate_hash end puts hash -- Posted via http://www.ruby-forum.com/.