[BUG]Morph>>updateableActionMap

Scott Wallace scott.wallace at squeakland.org
Mon Mar 18 21:01:42 UTC 2002


A terser way here is to use #valueOfProperty:ifAbsentPut:.  The 
#updateableActionMap method then reduces to:

updateableActionMap
   ^ self valueOfProperty: #actionMap ifAbsentPut: [self createActionMap]

   -- Scott


PS:  Morphs are not Dictionaries, so the fact that Morph protocols do 
not conform to Dictionary conventions is not IMO a flaw.  Outside of 
the Collection hierarchy, setters generally return self -- they do 
*not* return the value being set.   Notice, by way of analogy, that 
Collection.add: returns the addee, but Morph.addMorph: returns self.


At 11:15 AM -0800 3/18/02, Jim Benson wrote:

>  > I am not sure I see the two issues with your posted code, other than an
>>  assumption that #setProperty:toValue: returns the value, like all good
>>  Dictionary insertion protocols.
>
>#setProperty:toValue: is a bad dog ;-)

<snips>

>  > > I would think it would be along the lines of:
>>  >
>  > > updateableActionMap
>>  > | actionMap |
>>  >     ^ self valueOfProperty: #actionMap
>>  >         ifAbsent: [ actionMap := self setProperty: #actionMap
>  > > toValue: self
>  > > createActionMap.
>  > >             actionMap].



More information about the Squeak-dev mailing list