[squeak-dev] Re: singleton?

Bert Freudenberg bert at freudenbergs.de
Thu Apr 10 18:27:06 UTC 2008


On 10.04.2008, at 11:00, 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].


You cannot do this because it might find a PlotMorph in a different  
world (each project has a world).

- Bert -





More information about the Squeak-dev mailing list