The following should be done:
counts = Hash.new(0) ['A','A','A','A','B','B','C'].each { |name| counts[name] += 1 }
counts => {"A" => 4, "B" => 2, "C" => 1}
From the comments, the following one liner also does the same:
['A','A','A','A','B','B','C'].each_with_object(Hash.new(0)) { |l, o| o[l] += 1 }
source share