modify
Modify the value of a TVar
import arrow.fx.stm.TVar
import arrow.fx.stm.atomically
suspend fun main() {
//sampleStart
val tvar = TVar.new(10)
val result = atomically {
tvar.modify { it * 2 }
}
//sampleEnd
println(result)
}
Content copied to clipboard
modify(f) = write(f(read()))