Project

General

Profile

Actions

Bug #6142

closed

Enumerable::Lazy#zip doesn't rewind internal enumerators

Added by gregolsen (Innokenty Mikhailov) about 12 years ago. Updated about 11 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.0.0dev (2012-03-14 trunk 35013) [x86_64-linux]
Backport:
[ruby-core:43273]

Description

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.


Files

lazy_zip_to_a.diff (1.14 KB) lazy_zip_to_a.diff shugo (Shugo Maeda), 03/16/2012 12:03 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0