arrow-fx-stm / arrow.fx.stm / STM / plusAssign
open operator fun <A>
TQueue
<A>.plusAssign(a: A):
Unit
Append an element to the TQueue. Alias for STM.write.
import arrow.fx.stm.TQueue
import arrow.fx.stm.atomically
suspend fun main() {
//sampleStart
val tq = TQueue.new<Int>()
atomically {
tq += 2
}
//sampleEnd
println("Items in queue ${atomically { tq.flush() }}")
}
This function never retries.
open operator fun <K, V>
TMap
<K, V>.plusAssign(kv:
Pair
<K, V>):
Unit
Add a key value pair to the map
import arrow.fx.stm.TMap
import arrow.fx.stm.atomically
suspend fun main() {
//sampleStart
val tmap = TMap.new<Int, String>()
atomically {
tmap += (1 to "Hello")
}
//sampleEnd
}
open operator fun <A>
TSet
<A>.plusAssign(a: A):
Unit
Adds an element to the set. Alias of STM.insert.
import arrow.fx.stm.TSet
import arrow.fx.stm.atomically
suspend fun main() {
//sampleStart
val tset = TSet.new<String>()
atomically {
tset += "Hello"
}
//sampleEnd
}
Do you like Arrow?
✖