[squeak-dev] DictionaryIntegrityTest >> #testDictionaries failure

Chris Muller asqueaker at gmail.com
Wed May 15 01:44:27 UTC 2013


Yea, that would be better than dealing with the Association.  In fact
that would seem to bring a nice symmetry to the API since we have
#at:ifAbsent: + #at:ifPresent: pair, it stands to reason to have a
counterpart for at:ifAbsentPut:.  We should add it..

On Tue, May 14, 2013 at 6:57 PM, Bert Freudenberg <bert at freudenbergs.de> wrote:
> On 2013-05-15, at 00:03, Chris Muller <ma.chris.m at gmail.com> wrote:
>
>>>        | a |
>>>        a := dictionary associationAt: x.
>>>        a value: a value + 1
>>>
>>> instead of:
>>>
>>>        | v |
>>>        v := dictionary at: x.
>>>        dictionary at: x put: v + 1.
>>
>> Oh, nice..  Now I feel like I need to go through my code and see if
>> I'm doing it the double-lookup way..  :)  Thanks.
>
> How about this?
>
>         dictionary at: x ifPresentPut: [:v | v + 1].
>
> - Bert -
>
>


More information about the Squeak-dev mailing list