It took me about 15 minutes of staring before I saw it. That the
value at some found key could be nil, itself, and therefore would be
incorrect to answer the value of absentBlock. Good catch, and
probably illustrative of how having this method has saved me such
tricky bugs over the years. Thanks..
On Thu, Mar 4, 2010 at 10:35 PM, <
[hidden email]> wrote:
> Andreas Raab uploaded a new version of Collections to project The Trunk:
>
http://source.squeak.org/trunk/Collections-ar.326.mcz>
> ==================== Summary ====================
>
> Name: Collections-ar.326
> Author: ar
> Time: 4 March 2010, 8:34:47.942 pm
> UUID: e1937a7e-6776-7d4a-bd13-9956ad3ea411
> Ancestors: Collections-cmm.325
>
> Fix implementation of at:ifPresent:ifAbsent:.
>
> =============== Diff against Collections-cmm.325 ===============
>
> Item was changed:
> ----- Method: Dictionary>>at:ifPresent:ifAbsent: (in category 'accessing') -----
> at: key ifPresent: oneArgBlock ifAbsent: absentBlock
> "Lookup the given key in the receiver. If it is present, answer the value of evaluating the oneArgBlock with the value associated with the key, otherwise answer the value of absentBlock."
> + self at: key ifPresent:[:v| ^oneArgBlock value: v].
> + ^absentBlock value!
> - ^(self
> - at: key
> - ifPresent: oneArgBlock) ifNil: absentBlock!
>
>
>