WolframLang: Association, Delete by Key
Delete by Key, Modify Variable
KeyDropFrom[assoVar, key]
-
- remove the element with the specified key.
- modify the variable.
- return the new value of the variable.
xx = Association[ a -> 1, b -> 2]; KeyDropFrom[ xx, b ] xx === <|a -> 1|>
KeyDropFrom[assoVar, listOfKeys]
-
remove multiple elements.
xx = Association[ a -> 1, b -> 2, c -> 3, d -> 4]; KeyDropFrom[ xx, {a, c} ] === <|b -> 2, d -> 4|>
Delete by Key, No Modify Variable
KeyDrop
-
return a new association with some keys removed. (does not modify variable)
xx = Association[ a -> 1, b -> 2, c -> 3 ]; KeyDrop[ xx, b ] (* <|a -> 1, c -> 3|> *)