[squeak-dev] About a object life
Hans-Martin Mosner
hmm at heeg.de
Sat Nov 3 18:24:31 UTC 2012
Am 11/03/2012 03:26 PM, schrieb Edgar J. De Cleene:
> About a object life Folks:
>
> I wish know how old a object is.
>
> Any have code for this ?
>
> Thanks in advance
>
> Edgar
>
>
For existing objects, it's impossible to know how old they are.
For new objects, you can store a creation timestamp. Since this is very dependent on your actual needs, there is
probably no ready-to-use code, but the functionality is really simple (assuming you have an instance variable creationTime):
initialize
super initialize.
creationTime := DateAndTime now.
age
^DateAndTime now - creationTime
Cheers,
Hans-Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20121103/65a2dc74/attachment.htm
More information about the Squeak-dev
mailing list
|