Skip to content

Range#step behavior is different from core Ruby #6297

@joshuaclayton

Description

@joshuaclayton

When calling Range#step without a block, instead of returning an Enumerator, an array is returned. Why is this? I'm all for ActiveSupport extending behavior of core Ruby libraries, but to completely change the value that's returned seems wrong.

If this can't be changed, is there a way to opt out of this specific behavior?

>> (0..10).step(2)
=> #<Enumerator: 0..10:step(2)>
>> require 'active_support/core_ext'
=> true
>> (0..10).step(2)
=> [0, 2, 4, 6, 8, 10]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions