Actions
Bug #21174
closedRange#max called with an argument on a beginless Integer Range raises RangeError
Bug #21174:
Range#max called with an argument on a beginless Integer Range raises RangeError
Description
It seems surprising but instead of returning last n Integers Range#max(n) raises RangeError:
(nil..10).max(2)
# => (irb):3:in 'Range#max': cannot get the maximum of beginless range with custom comparison method (RangeError)
I would expect [9, 10] to be returned.
Updated by nobu (Nobuyoshi Nakada) 8 months ago
andrykonchin (Andrew Konchin) wrote:
I would expect
[9, 10]to be returned.
Range#max returns the elements in greater order.
I think it should be [10, 9], and (..10).last(2) should return [9, 10] without an exception too.
Updated by nobu (Nobuyoshi Nakada) 8 months ago
- Status changed from Open to Closed
Applied in changeset git|cbe3156f82ee8b68e734be58badb9b6a3adc8aa6.
[Bug #21174] [Bug #21175] Fix Range#max on beginless integer range
Actions