dict lappend
Adds elements to the list value of a key in the dict of a variable.
dict lappend VAR KEY ?VALUE ...?
Description
Adds each VALUE as one element to the end of the list that is the value of KEY in the dict of the variable VAR, and gives the new dict. A missing key starts as an empty list, and a VAR with no value starts as an empty dict. The value of the key must be a valid list.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| VAR | variable name | required | The variable with the dict. |
| KEY | string | required | The key of the list. |
| VALUE | any value | none | An element to add. |
Returns
The new value of VAR.
Examples
% set d {l {a b}}
> dict lappend d l c {d e}
l {a b c {d e}}
% set d {}
> dict lappend d l x
l x
Errors
% set d {l "a \{"}
> dict lappend d l x
unmatched open brace in list
-errorcode TCL VALUE LIST BRACE
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztcl 1.0.0-beta.1