Module: Enumerable

Defined in:
lib/goat/extn.rb

Instance Method Summary collapse

Instance Method Details

#tallyObject



34
35
36
37
38
39
40
# File 'lib/goat/extn.rb', line 34

def tally
  h = {}
  self.each do |elt|
    h[elt] = h.fetch(elt, 0) + 1
  end
  h
end