dict replace
Gives a copy of a dict with new values for some keys.
dict replace DICT ?KEY VALUE ...?
Description
Gives DICT with each KEY set to its VALUE. A key that exists keeps its place, and a new key goes at the end. The keys are of the top level only. With no KEY it gives DICT.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| DICT | dict | required | The dict. |
| KEY | string | none | A key. |
| VALUE | any value | none | The new value of the key before it. |
Returns
The new dict.
Examples
% dict replace {a 1 b 2} b 3 c 4
a 1 b 3 c 4
% dict replace {} a 1
a 1
Errors
% dict replace {a 1} b
wrong # args: should be "dict replace dictionary ?key value ...?"
-errorcode TCL WRONGARGS
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztcl 1.0.0-beta.1