Sha256: f6106b4f0b7120c3e2c2c769f2e44eeb38b76a76eb4f82037f5519f305741ab6

Contents?: true

Size: 538 Bytes

Versions: 1

Compression:

Stored size: 538 Bytes

Contents

module Polyfill
  module V2_4
    module Enumerable
      def chunk(*)
        return enum_for(:chunk) unless block_given?

        super
      end

      def sum(init = 0)
        acc =
          begin
            init.dup
          rescue TypeError
            init
          end

        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

1 entries across 1 versions & 1 rubygems

Version Path
polyfill-0.7.0 lib/polyfill/v2_4/enumerable.rb