ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:73550] [Ruby trunk - Bug #12029] [Open] Not all elements are yielded when count is given a block
       [not found] <redmine.issue-12029.20160128101933@ruby-lang.org>
@ 2016-01-28 10:19 ` jasonyeo88
  2016-01-28 11:06 ` [ruby-core:73551] [Ruby trunk - Bug #12029] " hanmac
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 4+ messages in thread
From: jasonyeo88 @ 2016-01-28 10:19 UTC (permalink / raw
  To: ruby-core

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/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:73551] [Ruby trunk - Bug #12029] Not all elements are yielded when count is given a block
       [not found] <redmine.issue-12029.20160128101933@ruby-lang.org>
  2016-01-28 10:19 ` [ruby-core:73550] [Ruby trunk - Bug #12029] [Open] Not all elements are yielded when count is given a block jasonyeo88
@ 2016-01-28 11:06 ` hanmac
  2016-01-28 12:44 ` [ruby-core:73552] " jasonyeo88
  2016-01-28 16:14 ` [ruby-core:73554] [Ruby trunk - Bug #12029] [Rejected] " nobu
  3 siblings, 0 replies; 4+ messages in thread
From: hanmac @ 2016-01-28 11:06 UTC (permalink / raw
  To: ruby-core

Issue #12029 has been updated by Hans Mackowiak.


you need splash:

```ruby
to_enum(:foo).count { |*e| e == [1, 2] } #=> 1
```

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

* 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/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:73552] [Ruby trunk - Bug #12029] Not all elements are yielded when count is given a block
       [not found] <redmine.issue-12029.20160128101933@ruby-lang.org>
  2016-01-28 10:19 ` [ruby-core:73550] [Ruby trunk - Bug #12029] [Open] Not all elements are yielded when count is given a block jasonyeo88
  2016-01-28 11:06 ` [ruby-core:73551] [Ruby trunk - Bug #12029] " hanmac
@ 2016-01-28 12:44 ` jasonyeo88
  2016-01-28 16:14 ` [ruby-core:73554] [Ruby trunk - Bug #12029] [Rejected] " nobu
  3 siblings, 0 replies; 4+ messages in thread
From: jasonyeo88 @ 2016-01-28 12:44 UTC (permalink / raw
  To: ruby-core

Issue #12029 has been updated by Jason Yeo.


Hans Mackowiak wrote:
> you need splash:
> 
> ```ruby
> to_enum(:foo).count { |*e| e == [1, 2] } #=> 1
> ```

hmmm, okay. I think I misunderstood how some Enumerable methods work. Thanks.

How do I close this issue by the way?

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

* 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/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:73554] [Ruby trunk - Bug #12029] [Rejected] Not all elements are yielded when count is given a block
       [not found] <redmine.issue-12029.20160128101933@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2016-01-28 12:44 ` [ruby-core:73552] " jasonyeo88
@ 2016-01-28 16:14 ` nobu
  3 siblings, 0 replies; 4+ messages in thread
From: nobu @ 2016-01-28 16:14 UTC (permalink / raw
  To: ruby-core

Issue #12029 has been updated by Nobuyoshi Nakada.

Description updated
Status changed from Open to Rejected

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

* Author: Jason Yeo
* Status: Rejected
* 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.

~~~ruby
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:

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




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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-01-28 15:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-12029.20160128101933@ruby-lang.org>
2016-01-28 10:19 ` [ruby-core:73550] [Ruby trunk - Bug #12029] [Open] Not all elements are yielded when count is given a block jasonyeo88
2016-01-28 11:06 ` [ruby-core:73551] [Ruby trunk - Bug #12029] " hanmac
2016-01-28 12:44 ` [ruby-core:73552] " jasonyeo88
2016-01-28 16:14 ` [ruby-core:73554] [Ruby trunk - Bug #12029] [Rejected] " nobu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).