Sha256: d0c010bcc2dff704483580d011bf8d298391d1aff7e515748c37994a81c5aecf

Contents?: true

Size: 233 Bytes

Versions: 6

Compression:

Stored size: 233 Bytes

Contents

unless Enumerable.method_defined? :tally
  module Enumerable
    def tally
      h = {}
      # NB: By spec, tally should return default-less hash
      each_entry { |item| h[item] = h.fetch(item, 0) + 1 }

      h
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
backports-3.25.0 lib/backports/2.7.0/enumerable/tally.rb
backports-3.24.1 lib/backports/2.7.0/enumerable/tally.rb
backports-3.24.0 lib/backports/2.7.0/enumerable/tally.rb
backports-3.23.0 lib/backports/2.7.0/enumerable/tally.rb
backports-3.22.1 lib/backports/2.7.0/enumerable/tally.rb
backports-3.22.0 lib/backports/2.7.0/enumerable/tally.rb