Deletes a pair by key and returns the value it held, or na when the key was not there.
The other pairs keep their order. Removing a missing key is not an error; it just returns na.
Use the returned value to act on what was removed, or ignore it.
Syntax
map.remove(id: any map type, key: series <type of the map's elements>) -> <value_type>
map.remove(key: series <type of the map's elements>) -> <value_type>Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | any map type | required | The map to take a pair out of. A key that is not there leaves it as it is. |
| key | series <type of the map's elements> | required | The key whose pair is removed. It has to match the key type of the map. |
Returns
<value_type>: The removed value, or na.
Example
//@version=6
indicator("map.remove: expire", overlay = false)
var open_ = map.new<int, float>()
if bar_index % 10 == 0
map.put(open_, bar_index, close)
if map.contains(open_, bar_index - 30)
map.remove(open_, bar_index - 30)
plot(map.size(open_), "Entries held")See also
Runs on Sidechair