Actions
Bug #17216
closedEnumerator::Chain doesn't support all Enumerator methods
Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19]
Description
Despite the fact that Enumerator::Chain
(returned by Enumerator#chain
) is supposed to inherit from Enumerator
, a lot of Enumerator
methods do not work on a chain instance throwing the following error:
TypeError (wrong argument type chain (expected enumerator))
The following code exhibit the problem:
[1, 2, 3].chain([4, 5, 6]).with_index.to_a
A workaround is to use each
(also work with map
, to_enum
, and others) to force a conversion back to a plain enumerator which seems superfluous:
[1, 2, 3].chain([4, 5, 6]).each.with_index.to_a
Actions
Like0
Like0Like0Like0