replace method

ImmortalMap<K, V> replace(
  1. K key,
  2. V newValue
)

Returns a copy of this map where the value of key is set to newValue if already present.

Returns the map unchanged if key is not present.

Implementation

ImmortalMap<K, V> replace(K key, V newValue) =>
    lookup(key).map((value) => add(key, newValue)).orElse(this);