Copies every pair of a second map into the first, overwriting values for keys that both maps have.
The first map gets the second map's pairs; the second map is unchanged. New keys are appended in the second map's order, and keys already present keep their position with the new value.
Both maps need the same key and value types.
Syntax
map.put_all(id: any map type, id2: any map type) -> void
map.put_all(id2: any map type) -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | any map type | required | The map that receives the pairs. Keys it already has take the value from the second map. |
| id2 | any map type | required | The map whose pairs are copied in. |
Returns
Nothing.
Example
//@version=6
indicator("map.put_all: overrides", overlay = false)
var base = map.new<string, float>()
var extra = map.new<string, float>()
if barstate.isfirst
map.put(base, "a", 1.0)
map.put(base, "b", 2.0)
map.put(extra, "b", 20.0)
map.put_all(base, extra)
plot(map.get(base, "b"), "b after merge")See also
Runs on Sidechair