aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext
diff options
context:
space:
mode:
authorSergey Nartimov <just.lest@gmail.com>2011-12-23 10:20:24 +0300
committerSergey Nartimov <just.lest@gmail.com>2011-12-23 10:20:24 +0300
commit1922283177e92823e760720889a60e5a9576648f (patch)
tree6502c1b671ef2ecd2fa18002aa4e0b2422f451ec /activesupport/lib/active_support/core_ext
parentead2593a54223498647555171e930f9cbe08759c (diff)
downloadrails-1922283177e92823e760720889a60e5a9576648f.tar.gz
rails-1922283177e92823e760720889a60e5a9576648f.tar.bz2
rails-1922283177e92823e760720889a60e5a9576648f.zip
remove Enumerable#each_with_object again
it come back occasionally in 367741ef
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r--activesupport/lib/active_support/core_ext/enumerable.rb21
1 files changed, 0 insertions, 21 deletions
diff --git a/activesupport/lib/active_support/core_ext/enumerable.rb b/activesupport/lib/active_support/core_ext/enumerable.rb
index 004014948e..77a5087981 100644
--- a/activesupport/lib/active_support/core_ext/enumerable.rb
+++ b/activesupport/lib/active_support/core_ext/enumerable.rb
@@ -26,27 +26,6 @@ module Enumerable
end
end
- # Iterates over a collection, passing the current element *and* the
- # +memo+ to the block. Handy for building up hashes or
- # reducing collections down to one object. Examples:
- #
- # %w(foo bar).each_with_object({}) { |str, hsh| hsh[str] = str.upcase }
- # # => {'foo' => 'FOO', 'bar' => 'BAR'}
- #
- # *Note* that you can't use immutable objects like numbers, true or false as
- # the memo. You would think the following returns 120, but since the memo is
- # never changed, it does not.
- #
- # (1..5).each_with_object(1) { |value, memo| memo *= value } # => 1
- #
- def each_with_object(memo)
- return to_enum :each_with_object, memo unless block_given?
- each do |element|
- yield element, memo
- end
- memo
- end unless [].respond_to?(:each_with_object)
-
# Convert an enumerable to a hash. Examples:
#
# people.index_by(&:login)