addWith method
Set only the value of the key specified by keys
in the map specified by others
.
others
で指定されたマップに、keys
で指定されたキーの値のみを設定します。
final main = {"c": 3, "d": 4};
final other = {"a": 1, "b": 2};
main.addWith(other, ["a"]); // {"a": 1, "c": 3, "d": 4}
Implementation
Map<K, V> addWith(Map<K, V> others, Iterable<K> keys) {
for (final key in keys) {
if (!others.containsKey(key)) {
continue;
}
// ignore: null_check_on_nullable_type_parameter
this[key] = others[key]!;
}
return this;
}