Skip to content
ChartDeck ChartScript docs Account Open the terminal

map

Maps: keys in insertion order (also callable as methods: m.put(k, v)).

#Functions

#map.clearfunction

Removes every key.

map.clear(id: map<K,V>)
ParameterTypeDescription
idmap<K,V>The map.

Example

ChartScriptFragmentOpen in editor
const m = map.new<string, float>()
m.put("a", 1.0)
m.clear()

Since ChartScript 1

#map.containsfunction

true when the key is in the map.

map.contains(id: map<K,V>, key: K): bool
ParameterTypeDescription
idmap<K,V>The array.
keyKThe key.

Returns bool.

Example

ChartScriptFragmentOpen in editor
const m = map.new<string, float>()
m.put("a", 1.0)
const b = m.contains("a")

Since ChartScript 1

#map.copyfunction

A shallow copy.

map.copy(id: map<K,V>): map<K,V>
ParameterTypeDescription
idmap<K,V>The map.

Returns map<K,V>.

Example

ChartScriptFragmentOpen in editor
const m = map.new<string, float>()
m.put("a", 1.0)
const m2 = m.copy()

Since ChartScript 1

#map.getfunction

The value of a key, or na.

map.get(id: map<K,V>, key: K): V
ParameterTypeDescription
idmap<K,V>The array.
keyKThe key.

Returns V.

Example

ChartScriptFragmentOpen in editor
const m = map.new<string, float>()
m.put("a", 1.0)
const v = m.get("a")

Since ChartScript 1

#map.keysfunction

A new array of the keys, in insertion order.

map.keys(id: map<K,V>): array<K>
ParameterTypeDescription
idmap<K,V>The map.

Returns array<K>.

Example

ChartScriptFragmentOpen in editor
const m = map.new<string, float>()
m.put("a", 1.0)
const ks = m.keys()

Since ChartScript 1

#map.new<K,V>function

A new empty map of the key and value types in <> (keys: int, float, bool, string, color or an enum).

Returns map<K,V>.

Example

ChartScriptFragmentOpen in editor
const m = map.new<string, float>()

Since ChartScript 1

#map.putfunction

Sets the value of a key; returns the previous value or na.

map.put(id: map<K,V>, key: K, value: V): V
ParameterTypeDescription
idmap<K,V>The array.
keyKThe key.
valueVThe value.

Returns V.

Example

ChartScriptFragmentOpen in editor
const m = map.new<string, float>()
m.put("a", 1.0)
m.put("b", 2.0)

Since ChartScript 1

#map.put_allfunction

Puts every key and value of id2 into id.

map.put_all(id: map<K,V>, id2: map<K,V>)
ParameterTypeDescription
idmap<K,V>The map.
id2map<K,V>The map to copy from.

Example

ChartScriptFragmentOpen in editor
const m = map.new<string, float>()
m.put("a", 1.0)
const m2 = map.new<string, float>()
m.put_all(m2)

Since ChartScript 1

#map.removefunction

Removes a key; returns its value or na.

map.remove(id: map<K,V>, key: K): V
ParameterTypeDescription
idmap<K,V>The array.
keyKThe key.

Returns V.

Example

ChartScriptFragmentOpen in editor
const m = map.new<string, float>()
m.put("a", 1.0)
const v = m.remove("a")

Since ChartScript 1

#map.sizefunction

The number of keys.

map.size(id: map<K,V>): int
ParameterTypeDescription
idmap<K,V>The map.

Returns int.

Example

ChartScriptFragmentOpen in editor
const m = map.new<string, float>()
m.put("a", 1.0)
const n = m.size()

Since ChartScript 1

#map.valuesfunction

A new array of the values, in insertion order.

map.values(id: map<K,V>): array<V>
ParameterTypeDescription
idmap<K,V>The map.

Returns array<V>.

Example

ChartScriptFragmentOpen in editor
const m = map.new<string, float>()
m.put("a", 1.0)
const vs = m.values()

Since ChartScript 1

The ChartScript documentation is in English for now; translations will follow.