safeUpdate method
void
safeUpdate(
- K key,
- V value
Updates only if the key already exists. Else, do nothing.
Example:
final map = {'a': 1, 'b': 2, 'c': 3};
map.safeUpdate('b', 4);
print(map); // Output: {'a': 1, 'b': 4, 'c': 3}
Implementation
void safeUpdate(K key, V value) {
if (containsKey(key)) {
this[key] = value;
}
}