member

open fun <K, V> TMap<K, V>.member(k: K): Boolean(source)

Check if a key k is in 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] = "Hello"

tmap.remove(1)
}
//sampleEnd
}

This function never retries.


open fun <A> TSet<A>.member(a: A): Boolean(source)

Check if an element is already in the set

import arrow.fx.stm.TSet
import arrow.fx.stm.atomically

suspend fun main() {
//sampleStart
val tset = TSet.new<String>()
val result = atomically {
tset.insert("Hello")
tset.member("Hello")
}
//sampleEnd
println("Result $result")
}