WolframLang: Association, Delete by Key

By Xah Lee. Date: .

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|>

WolframLang: Association (Key Value Pairs)

WolframLang in Depth

Basics

Comment, Print

String

Arithmetic

List

Expression, Atom, Head

Boolean

Conditional

Variable

Loop

Data Structure

Function

Pattern Matching

Advanced

Shell Tasks

Misc