[squeak-dev] Re: singleton?

Bernd Elkemann elkemann at web.de
Thu Apr 10 18:00:49 UTC 2008


> (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].




More information about the Squeak-dev mailing list