Skip to content

Range#count always returns size for Integer bounds #8955

@headius

Description

@headius

Range#count should yield to the given block and return a count of truthy results. Instead, when begin is an Integer and it is not "endless", it immediately returns the size of the range.

[] jruby $ jruby -e 'p (1..90).count { it <= 10 }'
90
[] jruby $ cx 3.4 ruby -e 'p (1..90).count { it <= 10 }'
10

The logic for count needs to be updated to current Ruby behavior. This regressed in JRuby 10 at 79ee920. JRuby 9.4 is unaffected because this code does not exist there and it falls back on Enumerable#count.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions