I was using Dates in a Range and my program was running very slowly. I
realized the cause was my calling Range#max when the range was large.
max implementation is to iterate though the entire range to determine
the max is. That’s unnecessary for Date (and many other types for that
matter) so I added the following to Range
alias_method :old_max, :max
(Date === first and first < last) ? last - 1 : old_max
It works (now my program runs fast) but is it The Ruby Way to specialize
standard container like Range for a specific type like this? Is it a
idea? Are there hidden gotchas I’m not seeing?