Project

General

Profile

Actions

Bug #20623

open

Unexpected behavior of blocks in Enumerator::Lazy#zip

Added by esad (Esad Hajdarevic) 8 days ago. Updated 7 days ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:118529]

Description

I've stumbled upon unexpected behaviour of lazy enumerators. My example:

[1].cycle.lazy.zip([2].cycle.lazy).map do |x|
  puts x.inspect
end.take(5).force
puts "---"
[1].cycle.lazy.zip([2].cycle.lazy).take(5).force.map do |x|
  puts x.inspect
end

The outputs (and variable assignment inside the block) differs

1
1
1
1
1
---
[1, 2]
[1, 2]
[1, 2]
[1, 2]
[1, 2]
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0