compareAndSwap

fun compareAndSwap(expected: T, new: T): T(source)

Compares value with expected and replaces it with new value if values matches. Legacy MM: If new value is not null and object is frozen, it must be frozen or permanent object.

Since Kotlin

1.3

Return

the old value

Parameters

expected

the expected value

new

the new value

Throws

with legacy MM if the value is not frozen or a permanent object