arrow-fx-stm / arrow.fx.stm / STM / set
open operator fun <A>
TArray
<A>.set(i:
Int
, a: A):
Unit
Set a variable in the TArray.
import arrow.fx.stm.TArray
import arrow.fx.stm.atomically
suspend fun main() {
//sampleStart
val tarr = TArray.new(size = 10, 2)
val result = atomically {
tarr[5] = 3
tarr[5]
}
//sampleEnd
println("Result $result")
}
Throws if i is out of bounds.
This function never retries.
open operator fun <K, V>
TMap
<K, V>.set(k: K, v: V):
Unit
Alias for STM.insert
import arrow.fx.stm.TMap
import arrow.fx.stm.atomically
suspend fun main() {
//sampleStart
val tmap = TMap.new<Int, String>()
atomically {
tmap[1] = "Hello"
}
//sampleEnd
}
Do you like Arrow?
✖