How to group by count in array without using loop June 10, 2023 by Tarik x = arr.inject(Hash.new(0)) { |h, e| h[e] += 1 ; h }