Raises Exception for Range#last(n) with Float::INFINITY
When a (Numeric) argument is given to
Range#last(n) for a Range with
Float::INFINITY, it runs into an infinite loop (see a small code snippet below).
There is no use case for the feature as far as I can think of, and it is hard to detect.
(6..Float::INFINITY).last(1) # => infinite loop!! (6..).last(1) # cannot get the last element of endless range (RangeError) (-Float::INFINITY..4).last(1) # can't iterate from Float (TypeError) (..4).last(1) # can't iterate from Float (TypeError)
Let me suggest raising an Exception (maybe RangeError, in the same way as an endless Range) when
last(n) is specified for a Range whose end value is
(6..Float::INFINITY).to_a has the same issue.
No data to display