mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Trivial optimization for Enumerable#each_with_object
This commit is contained in:
@@ -76,10 +76,10 @@ module Enumerable
|
||||
#
|
||||
# (1..5).each_with_object(1) { |value, memo| memo *= value } # => 1
|
||||
#
|
||||
def each_with_object(memo, &block)
|
||||
def each_with_object(memo)
|
||||
return to_enum :each_with_object, memo unless block_given?
|
||||
each do |element|
|
||||
block.call(element, memo)
|
||||
yield element, memo
|
||||
end
|
||||
memo
|
||||
end unless [].respond_to?(:each_with_object)
|
||||
|
||||
Reference in New Issue
Block a user