Question : rails array count occurrences of elements
Answered by : encouraging-emu-td2ada1jz884
names.inject(Hash.new(0)) { |total, e| total[e] += 1 ;total}
Source : https://stackoverflow.com/questions/5128200/how-to-count-identical-string-elements-in-a-ruby-array | Last Update : Tue, 14 Sep 21