Stay organized with collections
Save and categorize content based on your preferences.
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")}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Function: map.delete\n\nTakes a map, creates a copy of the map, and removes the item for the specified key.\n\nIf the key doesn't exist in the map, the function returns a copy of the\noriginal map.\n\nFor example, if you have `map1 = {key1: value1, key2: value2}` and `key =\nkey3`, `map.delete(map, key)` returns `{key1: value1, key2: value2}`.\n\nArguments\n---------\n\nReturns\n-------\n\nA copy of the map with the item specified by the key removed.\n\nRaised exceptions\n-----------------\n\nExamples\n--------\n\n```yaml\n# Remove item for specified key from copy of map\n# Returns `{\"key1\": \"hello\"}`\n- init:\n assign:\n - my_map: {\"key1\": \"hello\", \"key2\": \"world\"}\n- returnStep:\n return: ${map.delete(my_map, \"key2\")}\n```"]]