Sidechair

map.put_all()

Browse the reference

Copies every pair of a second map into the first, overwriting values for keys that both maps have.

Try it in the editor

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

Pine Script
map.put_all(id: any map type, id2: any map type) -> void
map.put_all(id2: any map type) -> void

Arguments

NameTypeDefaultDescription
idany map typerequiredThe map that receives the pairs. Keys it already has take the value from the second map.
id2any map typerequiredThe map whose pairs are copied in.

Returns

Nothing.

Example

Pine ScriptLayer overrides over defaultsOpen in editor
//@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