lib/polyfill/v2_4/array.rb in polyfill-0.6.0 vs lib/polyfill/v2_4/array.rb in polyfill-0.7.0

- old
+ new

@@ -1,9 +1,31 @@ -require_relative 'array/instance' - module Polyfill module V2_4 module Array - include Instance + 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