Sha256: d3edfda815622fcd5cdc35523760e7db459faf01cdf276f68e7b54bea1441478
Contents?: true
Size: 603 Bytes
Versions: 4
Compression:
Stored size: 603 Bytes
Contents
# frozen_string_literal: true unless [].respond_to?(:tally) module RubyNext module Core module EnumerableTally def tally each_with_object({}) do |v, acc| acc[v] ||= 0 acc[v] += 1 end end end end end RubyNext.module_eval do refine Enumerable do include RubyNext::Core::EnumerableTally end # Refine Array seprately, 'cause refining modules is vulnerable to prepend: # - https://bugs.ruby-lang.org/issues/13446 refine Array do include RubyNext::Core::EnumerableTally end end end
Version data entries
4 entries across 4 versions & 2 rubygems