Sha256: 0a8996b495aca1982fb5d001fb61afaf0ad1b56081ee3a3e00e91653fc0714d4

Contents?: true

Size: 537 Bytes

Versions: 9

Compression:

Stored size: 537 Bytes

Contents

require_relative 'numeric'

module Polyfill
  module V2_4
    module Enumerable
      using Polyfill(Numeric: %w[#dup], version: '2.4')

      def chunk(*)
        return enum_for(:chunk) unless block_given?

        super
      end

      def sum(init = 0)
        acc = init.dup

        each do |elem|
          acc += block_given? ? yield(elem) : elem
        end

        acc
      end

      def uniq
        if block_given?
          to_a.uniq(&::Proc.new)
        else
          to_a.uniq
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
polyfill-1.9.0 lib/polyfill/v2_4/enumerable.rb
polyfill-1.8.0 lib/polyfill/v2_4/enumerable.rb
polyfill-1.7.0 lib/polyfill/v2_4/enumerable.rb
polyfill-1.6.0 lib/polyfill/v2_4/enumerable.rb
polyfill-1.5.0 lib/polyfill/v2_4/enumerable.rb
polyfill-1.4.0 lib/polyfill/v2_4/enumerable.rb
polyfill-1.3.0 lib/polyfill/v2_4/enumerable.rb
polyfill-1.2.0 lib/polyfill/v2_4/enumerable.rb
polyfill-1.1.0 lib/polyfill/v2_4/enumerable.rb