From: Brian Buckley Date: 2006-02-19T03:29:38+09:00 Subject: Specializing Range ------=_Part_4320_11562381.1140287355769 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hello, 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. The max implementation is to iterate though the entire range to determine what the max is. That's unnecessary for Date (and many other types for that matter) so I added the following to Range class Range alias_method :old_max, :max def max (Date =3D=3D=3D first and first < last) ? last - 1 : old_max end end It works (now my program runs fast) but is it The Ruby Way to specialize a standard container like Range for a specific type like this? Is it a bad idea? Are there hidden gotchas I'm not seeing? Brian ------=_Part_4320_11562381.1140287355769--