//arrow-fx-stm/arrow.fx.stm/STM/plusAssign

plusAssign

common open operator fun <A> TQueue<A>.plusAssign(a: A)

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.

common open operator fun <K, V> TMap<K, V>.plusAssign(kv: Pair<K, V>)

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
}

common open operator fun <A> TSet<A>.plusAssign(a: A)

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?

Arrow Org
<