lib/polyfill/v2_4/enumerable.rb in polyfill-0.7.0 vs lib/polyfill/v2_4/enumerable.rb in polyfill-0.8.0
- old
+ new
@@ -1,20 +1,19 @@
+require_relative 'numeric'
+
module Polyfill
module V2_4
module Enumerable
+ using Polyfill(Numeric: %w[#dup])
+
def chunk(*)
return enum_for(:chunk) unless block_given?
super
end
def sum(init = 0)
- acc =
- begin
- init.dup
- rescue TypeError
- init
- end
+ acc = init.dup
each do |elem|
acc += block_given? ? yield(elem) : elem
end