updateOrNull

fun <K, V> ObservableMutableMap<K, V>.updateOrNull(key: K, valueUpdate: V.() -> Unit): V?

Updates the value associated with the given key in the map by applying the provided transformation function. If the key does not exist or its current value is null, no operation is performed, and null is returned.

Return

The updated value if the key exists and its value is not null; otherwise, null.

Parameters

key

The key whose associated value is to be updated.

valueUpdate

A function that defines how the current value should be updated.