[ruby-core:73550] [Ruby trunk - Bug #12029] [Open] Not all elements are yielded when count is given a block

From: jasonyeo88@...
Date: 2016-01-28 10:19:33 UTC
List: ruby-core #73550
Issue #12029 has been reported by Jason Yeo.

----------------------------------------
Bug #12029: Not all elements are yielded when count is given a block
https://bugs.ruby-lang.org/issues/12029

* Author: Jason Yeo
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: 2.3.0
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
When count is called on an enumerable that yields multiple elements, not all elements are yielded to the block.

~~~
def foo
  yield 1, 2
end

to_enum(:foo).count { |e| e == [1, 2] }
# Returns: 0
# Expected: 1
~~~

It appears that only the first element is yielded:

~~~
to_enum(:foo).count { |e| p e; e == [1, 2] }
# Prints 1
~~~




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next