Sha256: 0591e579082c9e8e61b2df2cc0abc276a0424aed9e2f11324b36e5a2037633fe

Contents?: true

Size: 512 Bytes

Versions: 1

Compression:

Stored size: 512 Bytes

Contents

module Polyfill
  module V2_4
    module Array
      def concat(*others)
        return super if others.length == 1

        acc = [].concat(self)
        others.each do |other|
          acc.concat(other)
        end

        replace(acc)
      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
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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