Project

General

Profile

Actions

Bug #11811

closed

Chaining lazy enumerators causes duplicate ouput

Added by cabeer (Chris Beer) over 8 years ago. Updated over 8 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.3.0preview2 (2015-12-11 trunk 53028) [x86_64-darwin15]
[ruby-core:72083]

Description

In Ruby 2.3.0-preview2, I'm seeing a change in behavior using lazy enumerators with select/reject and the & operator:

irb(main):037:0> %w(1 2 3).lazy.reject(&:empty?).each { |x| puts x }
1
1
2
2
3
3

Note that the output is doubled. However, if I don't use the & shorthand, the output is as expected:

irb(main):038:0> %w(1 2 3).lazy.reject { |x| x.empty? }.each { |x| puts x }
1
2
3
=> nil

And in Ruby 2.2.3, both variants produced the same result:

irb(main):001:0> %w(1 2 3).lazy.reject(&:empty?).each { |x| puts x }
1
2
3
=> nil


Files

vm_caller_setup_arg_block.diff (1.03 KB) vm_caller_setup_arg_block.diff shugo (Shugo Maeda), 12/16/2015 01:39 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0