module Enumerable

def tally_with_hash_argument(h = ::Backports::Undefined)

def tally_with_hash_argument(h = ::Backports::Undefined)
  return tally_without_hash_argument if h.equal? ::Backports::Undefined
  h = ::Backports.coerce_to_hash(h)
  each_entry { |item| h[item] = h.fetch(item, 0) + 1 }
  h
end