From 1922283177e92823e760720889a60e5a9576648f Mon Sep 17 00:00:00 2001 From: Sergey Nartimov Date: Fri, 23 Dec 2011 10:20:24 +0300 Subject: remove Enumerable#each_with_object again it come back occasionally in 367741ef --- .../lib/active_support/core_ext/enumerable.rb | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'activesupport/lib/active_support/core_ext') 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) -- cgit v1.2.3