Takes a map, creates a copy of the map, and removes the item for the specified key.
If the key doesn't exist in the map, the function returns a copy of the original map.
For example, if you have map1 = {key1: value1, key2: value2}
and key =
key3
, map.delete(map, key)
returns {key1: value1, key2: value2}
.
Arguments
Arguments | |
---|---|
map |
The map to delete from. |
key |
A string that represents the specified key to remove from the map. |
Returns
A copy of the map with the item specified by the key removed.
Raised exceptions
Exceptions | |
---|---|
TypeError |
If map is not a map (dictionary) or the key is not a string. |
Examples
# Remove item for specified key from copy of map # Returns `{"key1": "hello"}` - init: assign: - my_map: {"key1": "hello", "key2": "world"} - returnStep: return: ${map.delete(my_map, "key2")}