Unverified Commit 951ebbaf authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #3988 from ksss/each_with_object

Refactoring for `Enumerable#each_with_object`
parents a072015c e683c95e
......@@ -610,9 +610,7 @@ module Enumerable
# #=> [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
#
def each_with_object(obj=nil, &block)
raise ArgumentError, "wrong number of arguments (0 for 1)" if obj.nil?
def each_with_object(obj, &block)
return to_enum(:each_with_object, obj) unless block
self.each {|*val| block.call(val.__svalue, obj) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment