aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-03-21 04:00:07 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2009-03-21 04:35:16 -0700
commit8d1d813b66d626dfaf82fa360907c7bf681180e5 (patch)
treea689a5f261d60094e3e05d8390949bfeeee95cd2 /activesupport
parent051bab5bd2d52bc4b3abf1a3dfb086c4c3fd345e (diff)
downloadrails-8d1d813b66d626dfaf82fa360907c7bf681180e5.tar.gz
rails-8d1d813b66d626dfaf82fa360907c7bf681180e5.tar.bz2
rails-8d1d813b66d626dfaf82fa360907c7bf681180e5.zip
Simplify Enumerable#each_with_object
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/enumerable.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/core_ext/enumerable.rb b/activesupport/lib/active_support/core_ext/enumerable.rb
index a7eaccfed7..8309b617ae 100644
--- a/activesupport/lib/active_support/core_ext/enumerable.rb
+++ b/activesupport/lib/active_support/core_ext/enumerable.rb
@@ -77,11 +77,10 @@ module Enumerable
# (1..5).each_with_object(1) { |value, memo| memo *= value } # => 1
#
def each_with_object(memo, &block)
- returning memo do |m|
- each do |element|
- block.call(element, m)
- end
+ each do |element|
+ block.call(element, memo)
end
+ memo
end unless [].respond_to?(:each_with_object)
# Convert an enumerable to a hash. Examples: