Issue #6142 has been updated by shugo (Shugo Maeda).

Status changed from Feedback to Closed

This issue should be discussed in #7691 and #7696.
----------------------------------------
Bug #6142: Enumerable::Lazy#zip doesn't rewind internal enumerators
https://bugs.ruby-lang.org/issues/6142#change-35482

Author: gregolsen (Innokenty Mikhailov)
Status: Closed
Priority: Normal
Assignee: shugo (Shugo Maeda)
Category: 
Target version: 
ruby -v: ruby 2.0.0dev (2012-03-14 trunk 35013) [x86_64-linux]


All enumerables passed to Enumerable::Lazy#zip are converted into lazy enumerators.
When result evaluated - ruby iterates over this enumerators while calling #next to retrieve the next value.
But those enumerators are not rewinded:

  a = (1..3).lazy.zip('a'..'z')
  a.to_a #=> [[1, "a"], [2, "b"], [3, "c"]]
  a.to_a #=> [[1, "d"], [2, "e"], [3, "f"]]

I believe that is not the desired behavior here and a.to_a should always return the same value.


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