setIfMissing method
V
setIfMissing(
- K key,
- V value
Inserts a key-value pair into the map if the key does not already exist.
If the key exists, its associated value is returned; otherwise, the new value is inserted and then returned.
Implementation
V setIfMissing(K key, V value) {
if (!containsKey(key)) {
this[key] = value;
return value;
}
return this[key] as V;
}