Range relies entirely on Enumerable to implement #min and #max, which
in turn implements these operations using #to_a. This becomes a
problem with ranges of floats, for example:
TypeError: can’t iterate from Float
from (irb):9:in `each’
Not to mention that it becomes inefficient to expand the whole range
into array, such as for very large integers:
(Tends to run out of memory.)
I think it makes more sense to implement these operations in terms of
<=>, like so:
(self.first <=> self.last) <= 0 ? self.first : nil
(self.first <=> self.last) <= 0 ? self.last : nil
I don’t see any reason to rely on expanding the range using
Enumerable#to_a, since the operations can be implemented purely in
terms of the range boundaries.
I would be happy to submit a patch.