dict exists
Tests whether a path of keys exists.
dict exists DICT KEY ?KEY ...?
Description
Gives 1 when DICT has the path of keys, else 0. A value on the path that is not a dict gives 0, and so does a DICT that is not a valid dict: the command never fails on its values.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| DICT | dict | required | The dict. |
| KEY | string | required | The keys of the path, at least one. |
Returns
1 or 0.
Examples
% dict exists {a 1} a
1
% dict exists {a {b 2}} a b
1
% dict exists {a 1} a b
0
# A list with an odd count of elements is not a dict.
% dict exists {a 1 b} a
0
Errors
% dict exists {a 1}
wrong # args: should be "dict exists dictionary key ?key ...?"
-errorcode TCL WRONGARGS
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztcl 1.0.0-beta.1