map.new<type,type>() - Pine Script Function
map.new<type,type>()
Section titled “map.new<type,type>()”Overview
Section titled “Overview”Creates a new map object: a collection that consists of key-value pairs, where all keys are of the keyType, and all values are of the valueType.
Syntax
Section titled “Syntax”map.new<keyType, valueType>() → map<keyType, valueType>Returns
Section titled “Returns”The ID of a map object which may be used in other map.*() functions.
Remarks
Section titled “Remarks”- Each key is unique and can only appear once. When adding a new value with a key that the map already contains, that value replaces the old value associated with the key.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6indicator("map.new<string, int> example")a = map.new<string, int>()a.put("example", 1)label.new(bar_index, close, str.tostring(a.get("example")))