update

open fun <K, V> TMap<K, V>.update(k: K, fn: (V) -> V)

Update a value at a key if it exists.

import arrow.fx.stm.TMap
import arrow.fx.stm.atomically

suspend fun main() {
//sampleStart
val tmap = TMap.new<Int, String>()
val result = atomically {
tmap[2] = "Hello"
tmap.update(2) { it.reversed() }
tmap[2]
}
//sampleEnd
println("Result $result")
}