map
into self
.If a same key exists in map
and self
, then the value in self is discarded.
var x = new HashMap[String, Int]
x["four"] = 4
x["five"] = 5
var y = new HashMap[String, Int]
y["four"] = 40
y["nine"] = 90
x.add_all y
assert x["four"] == 40
assert x["five"] == 5
assert x["nine"] == 90
# Add each (key,value) of `map` into `self`.
# If a same key exists in `map` and `self`, then the value in self is discarded.
#
# var x = new HashMap[String, Int]
# x["four"] = 4
# x["five"] = 5
# var y = new HashMap[String, Int]
# y["four"] = 40
# y["nine"] = 90
# x.add_all y
# assert x["four"] == 40
# assert x["five"] == 5
# assert x["nine"] == 90
fun add_all(map: MapRead[K, V])
do
var i = map.iterator
while i.is_ok do
self[i.key] = i.item
i.next
end
end
lib/core/collection/abstract_collection.nit:728,2--748,4