tryTake

open fun <A> TMVar<A>.tryTake(): A?(source)

Same as TMVar.take except it returns null if the TMVar is empty and thus never retries.

import arrow.fx.stm.TMVar
import arrow.fx.stm.atomically

suspend fun main() {
//sampleStart
val tmvar = TMVar.empty<Int>()
val result = atomically {
tmvar.tryTake()
}
//sampleEnd
println("Result $result")
println("New value ${atomically { tmvar.tryTake() } }")
}