WolframLang: Association, Delete by Key
Delete by Key, Modify Variable
KeyDropFrom[assocVar, key]
- remove the element with the specified key.
KeyDropFrom
xx = Association[ a -> 1, b -> 2]; KeyDropFrom[ xx, b ] === <|a -> 1|>
KeyDropFrom[assocVar, {key1, key2 etc}]
- 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)
KeyDrop
xx = Association[ a -> 1, b -> 2, c -> 3 ]; KeyDropFrom[ xx, b ] === <|a -> 1, c -> 3|>