Actions
Feature #19294
openEnumerator.product works incorrectly with consuming enumerators
Status:
Open
Assignee:
-
Target version:
-
Description
s = StringIO.new('abc')
Enumerator.product([1, 2, 3], s.each_char).to_a
# Expected: => [[1, "a"], [1, "b"], [1, "c"], [2, "a"], [2, "b"], [2, "c"], [3, "a"], [3, "b"], [3, "c"]]
# Actual: => [[1, "a"], [1, "b"], [1, "c"]]
The implementation consumes the non-first enumerator to produce the first combination.
Somewhat related to the dilemma of consuming and non-consuming enumerators (#19061).
PS: I noticed I don't understand why it is Enumerator.product
and not Enumerable#product
, but probably it is too late to raise the questions :(
Actions
Like0
Like0Like0Like0