Hi all,
recently I stumbled upon an extension method for Dictionary which *might* fit well into the Trunk:
Dictionary >> #at: key ifAbsentPut: startBlock ifPresentPut: nextBlock
"(c) 2020 Basti Kruck und Marcel Taeumel. :-)" (self includesKey: key) ifFalse: [
^ self at: key put: startBlock value]. ^ self
at: key
put: (nextBlock value: (self at: key))
Usage:
counter := counters at: key ifAbsentPut: [0] ifPresentPut: [:i | i + 1]
What do you think, should we copy this into the Trunk? Or is it just fine to do something like this instead at the sender side:
counter := counters at: key put: (counters at: key ifAbsent: [0] ifPresent: [:i | i + 1])