Permalink
Browse files

Trivial optimization for Enumerable#each_with_object

  • Loading branch information...
1 parent 816abec commit f061ffd9f4e7f7d612d4baa25e8075bb23896275 @marcandre marcandre committed Jul 23, 2011
Showing with 2 additions and 2 deletions.
  1. +2 −2 activesupport/lib/active_support/core_ext/enumerable.rb
@@ -76,10 +76,10 @@ def sum(identity = 0, &block)
#
# (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)

0 comments on commit f061ffd

Please sign in to comment.