rails array jumlah kejadian elemen

names.inject(Hash.new(0)) { |total, e| total[e] += 1 ;total}
Encouraging Emu