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))

See https://github.com/hpi-swa/vivide/blob/c4ac5ea562bd563358d52ee41c149a3fbcffd90e/repository/Vivide.package/Dictionary.extension/instance/at.ifAbsentPut.ifPresentPut..st.


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])

Also, I'm not sure about the order of arguments.

Best,
Christoph