range_operators icon indicating copy to clipboard operation
range_operators copied to clipboard

rangify includes the last value of ranges with excluded end

Open durkie opened this issue 6 years ago • 0 comments

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.

durkie avatar Feb 26 '19 16:02 durkie