Sha256: e11598acdca380b0002ef70b3329ece956140882854b2123e5f2b48c1af1c131

Contents?: true

Size: 572 Bytes

Versions: 9

Compression:

Stored size: 572 Bytes

Contents

require_relative 'numeric'

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

      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 = init.dup

        for i in 0..(size - 1) # rubocop:disable Style/For
          elem = self[i]
          acc += block_given? ? yield(elem) : elem
        end

        acc
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

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