Actions
Feature #16838
openEnumerator::ArithmeticSequence missing allocator for #clone and #dup
Status:
Open
Assignee:
-
Target version:
-
Description
In Ruby 2.5, with an Enumerator:
1.step.clone
#=> Enumerator
In Ruby 2.6, with an Enumerator::ArithmeticSequence:
1.step.clone
#!> TypeError (allocator undefined for Enumerator::ArithmeticSequence)
I've gotten around it in 2.6 and 2.7 by checking if an enum is an ArithmeticSequence and reconstituting a new one if so:
Range.new(enum.begin, enum.end, enum.exclude_end?) % enum.step
Instead of cloning:
enum.clone
I filed this as a bug rather than feature, since it seemed like a breaking change and I wasn't sure if it was intentional. Thank you!
Actions
Like0
Like0Like0