putIfAbsent

fun putIfAbsent(key: Key, value: Value): Value?(source)

Maps the specified key to value if it is not already mapped. If the map already contains a value for key, it returns the existing value and does not modify the map.

Return

the previous value associated with key, or null if there was no mapping

Parameters

key

the key with which the specified value is to be associated

value

the value to be associated with the specified key