[squeak-dev] Re: singleton?
Matthew Fulmer
tapplek at gmail.com
Thu Apr 10 18:38:26 UTC 2008
On Thu, Apr 10, 2008 at 08:00:49PM +0200, Bernd Elkemann wrote:
>> (World findA: PlotMorph) ifNil: [PlotMorph new openInWorld; yourself]
> write this in a class-method named e.g. "theInstance".
>
> But i prefer the following because it does not depend on World and does not
> need a "find" (my guess is that it takes longer the more morphs are in the
> World):
> class-side method:
> theInstance
> ^(self allInstances at: 1 ifAbsent: [self new].
allInstances is much slower than World findA:;
- allInstances searches every object in memory
- findA: searches the "submorphs" ivar of the World
Also, do you really want to use a PlotMorph that is not visible
in your world?
--
Matthew Fulmer -- http://mtfulmer.wordpress.com/
More information about the Squeak-dev
mailing list
|