Version 1 of array set

Updated 2008-03-12 18:24:41 by willdye

array set arrayName list

Sets the values of one or more elements in arrayName. List must have a form like that returned by array get, consisting of an even number of elements. Each odd-numbered element in list is treated as an element name within arrayName, and the following element in list is used as a new value for that array element. If the variable arrayName does not already exist and list is empty, arrayName is created with an empty array value.

Note that if the array has existing elements, array set will append the new elements to the existing array. The existing elements will not be removed. In contrast, the normal set command will replace existing data.

For example, array set spam {} will not clear out the array variable spam. An alternative is unset, perhaps in the form: if {info exists spam} {unset spam}.


See also:


Category Command - Tcl syntax help