Hi,
In message "[ruby-talk:11598] Re: (Im)mutable Time (was: Time without seconds(updated/fixed))"
on 01/02/27, Kevin Smith <sent / qualitycode.com> writes:
|>I think I could think otherwise if I'd know a strong enough reason to make
|>the change, and I think I don't.
|
|The example that was raised seemed to point out
|the need to me, but I guess there's another
|approach. Rather than having MyTime inherit from
|Time, it could delegate to it. That allows things
|like MyTime t = t.new; t += tenSeconds.
I don't have strong objection about making Time mutable.
Since it is already mutable in some sense. Try:
t = Time.now
p t
p t.utc
p t
|Hmmmm. Back to the original suggestion. When you
|have a string and call << I assume the string is
|'muted' (changed). Similarly, when you have an
|Integer and call += the integer is changed. To
|me, Time seems to fall into this same category of
|object, and thus I would expect it to be
|mutable.
Integers are NOT changed. They are immutable. The value of the
variable has changed in this case.
matz.