From: Dan Kubb <dan.kubb@...>
Date: 2012-03-16T15:23:48+09:00
Subject: [ruby-core:43338] [ruby-trunk - Bug #6157][Open] Enumerable::Lazy#select does not handle multiple yield arguments


Issue #6157 has been reported by Dan Kubb.

----------------------------------------
Bug #6157: Enumerable::Lazy#select does not handle multiple yield arguments
https://bugs.ruby-lang.org/issues/6157

Author: Dan Kubb
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: ruby 2.0.0dev (2012-03-15 trunk 35028) [x86_64-darwin11.3.0]


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]]


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