compareAndSet

fun compareAndSet(expected: T, new: T): Boolean(source)

Compares value with expected and replaces it with new value if values matches. Note that comparison is identity-based, not value-based.

Since Kotlin

1.3

Return

true if successful

Parameters

expected

the expected value

new

the new value