to_s shouldn't be figuring out the string representation every time it's
run. It makes more sense to run that code whenever the object itself
changes. That's what I've done in this version.
Come to think of it... the even lazier approach would be to wait to
compute the string on the first run of to_s, and have every subsequent
call to to_s return a instance variable, unless the object is changed.
dayRange.rb (2.05 KB)
Begin forwarded message: