Actions
Bug #17814
closedinconsistent Array.zip behavior
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
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
Updated by dzwdz (Kuba Prawdziwe-Nazwisko) over 3 years 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
Updated by mame (Yusuke Endoh) over 3 years ago
Good catch! https://github.com/ruby/ruby/pull/4389
Updated by mame (Yusuke Endoh) over 3 years 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
Like0
Like0Like0Like0