dict unset removes a key and its associated value from a dictionary of dictionaries.
dict unset unsets one element from the dictionary of dictionaries named dictVarName. They key arguments form a path to the key to unset. The variable is modified, and its new value is returned. If the given key doesn't exist in the dict, no change is made. If a key path is given, all keys except the last must exist.
% # Simple example: % set data {a 1 b 2} a 1 b 2 % dict unset data a ;# Remove key "a" and its corresponding value "1" b 2 % set data ;# Verify that variable is modified. b 2 % dict unset data nonexistent ;# Check nonexistent key handling b 2
% # Example using nested dicts: % set data {row1 {col1 val11 col2 val12} row2 {col1 val21 col2 val22}} row1 {col1 val11 col2 val12} row2 {col1 val21 col2 val22} % dict unset data row2 col2 ;# Remove element "col2" in nested dict "row2" row1 {col1 val11 col2 val12} row2 {col1 val21} % dict unset data row1 ;# Remove element "row1" row2 {col1 val21} % set data ;# Verify again that variable is modified row2 {col1 val21} % dict unset data row2 col2 ;# Check nonexistent key handling row2 {col1 val21} % dict unset data row1 col2 ;# Check nonexistent nested dict handling key "row1" not known in dictionary
A synonym for
dict unset dictname key
is
dict update dictname key key {unset key}