Skip to content

rangify includes the last value of ranges with excluded end #4

@durkie

Description

@durkie

At the beginning of array_operator_definitions.rb there is a warning:

#Assumes inclusive ranges (ie. 1..4) and range.first <= range.last.

but for what it's worth, it seems like it comes down to the comparison_value method:

def comparison_value(value, position)
  return value if value.class != Range
  position == :first ? value.first : value.last
end

Replacing value.last with value.max would let this work with exclusive ranges too, and I can confirm after making this change that it does operate well with excluded end ranges and continues to pass all tests.

happy to submit a PR, but I also know this is a pretty old gem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions