Project

General

Profile

Actions

Bug #17814

closed

inconsistent Array.zip behavior

Added by dzwdz (Kuba Prawdziwe-Nazwisko) 27 days ago. Updated 26 days ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
[ruby-core:103513]

Description

When using Array.zip with an enumerator, it "eats" an additional element off the end of it. Enumerable.zip has the expected behavior of only taking as many elements as it needs to.

I've tested this on local ruby 2.7.2 and ruby 3.0.1 on carc.in.


Files

test.rb (232 Bytes) test.rb dzwdz (Kuba Prawdziwe-Nazwisko), 04/19/2021 03:00 PM
output.txt (184 Bytes) output.txt dzwdz (Kuba Prawdziwe-Nazwisko), 04/19/2021 03:00 PM

Updated by dzwdz (Kuba Prawdziwe-Nazwisko) 27 days ago

note: sorry for the weird Fiber thing in the example code, that's not related to the bug

an enumerator created with

step = 0.step
e = Enumerator.produce { step.next }

would also have the same bug

Actions #3

Updated by mame (Yusuke Endoh) 26 days ago

  • Status changed from Open to Closed

Applied in changeset git|fb04c69418ceee696a114fe31279cf3a5ea16d30.


array.c (rb_ary_zip): take only as many as needed from an Enumerator (#4389)

[Bug #17814]

Actions

Also available in: Atom PDF