Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #4142 from lest/remove-1-8-code

remove Enumerable#each_with_object again
  • Loading branch information...
commit 4379c45756eaaf769a10980c5e778648c082aac9 2 parents ead2593 + 1922283
@josevalim josevalim authored
Showing with 0 additions and 21 deletions.
  1. +0 −21 activesupport/lib/active_support/core_ext/enumerable.rb
View
21 activesupport/lib/active_support/core_ext/enumerable.rb
@@ -26,27 +26,6 @@ def sum(identity = 0, &block)
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)
Please sign in to comment.
Something went wrong with that request. Please try again.