tcl Variables Deleting variable/s


The unset command is used to remove one or more variables.

unset ?-nocomplain? ?--? ?name name name name?
  • Each name is a variable name specified in any of the ways acceptable to the set command.
  • If a name refers to an element of an array then that element is removed without affecting the remainder of the array.
  • If a name consists of an array name with no index in parentheses, then the entire array is deleted.
  • If -nocomplain is given as the first argument, then all possible errors are suppressed from the command's output.
  • The option -- indicates the end of the options, and should be used if you wish to remove a variable with the same name as any of the options.
% set x 235
% set x
% unset x
% set x
can't read "x": no such variable