Issue #707 has been updated by Brian Candler.


Here is another (shorter and simpler)

class Enumerator
  def filter(&blk)
    self.class.new do |y|
      each do |*input|
        blk.call(y, *input)
      end
    end
  end
end

a = (1..1_000_000_000).to_enum
a.filter { |out,inp| out << inp if inp % 2 == 0 }.
  filter { |out,inp| out << inp+100 }.
  with_index.each { |inp,c| puts inp; break if c > 10 }

----------------------------------------
http://redmine.ruby-lang.org/issues/show/707

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