From: 7stud -- Date: 2012-09-17T13:03:10+09:00 Subject: Re: Breaking Down the Block > recur = array.inject(Hash.new(0)) {|k,v| k[v]+=1; k} Horrible variable names are the culprit again. hash = {} p hash[10] --output:-- nil hash = Hash.new(0) p hash[10] --output:-- 0 array = [10, 20, 30, 30, 40] result = array.inject(Hash.new(0)) {|hash, array_element| hash[array_element] += 1; hash} p result --output:-- {10=>1, 20=>1, 30=>2, 40=>1} -- Posted via http://www.ruby-forum.com/.