Project

General

Profile

Actions

Bug #6157

closed

Enumerable::Lazy#select does not handle multiple yield arguments

Added by dkubb (Dan Kubb) over 12 years ago. Updated over 12 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.0.0dev (2012-03-15 trunk 35028) [x86_64-darwin11.3.0]
Backport:
[ruby-core:43338]

Description

When the #each method yields more than one argument, Enumerable::Lazy#select only accepts the first argument, e.g.:

class MultiYield
include Enumerable
def each
yield 1, 2, 3
end
end

multi = MultiYield.new
multi.lazy.select { |e| e == [1, 2, 3] }.to_a # => []

The above code will not match. "e" will be equal to 1, rather than [1, 2, 3].

For reference, here is the non-lazy version, which matches the expected values:

multi = MultiYield.new
multi.select { |e| e == [1, 2, 3] }.to_a # => [[1, 2, 3]]

Updated by shugo (Shugo Maeda) over 12 years ago

  • Status changed from Open to Closed

Dan Kubb wrote:

When the #each method yields more than one argument, Enumerable::Lazy#select only accepts the first argument, e.g.:

The bug has already been fixed in r35043. Please try the latest revision.

Actions

Also available in: Atom PDF

Like0
Like0