dict size

Gives the count of keys of a dict.

dict size DICT

Description

Gives the count of keys of DICT. A key that is twice in the list counts once. An empty dict has size 0.

Arguments

ArgumentTypeDefaultDescription
DICTdictrequiredThe dict.

Returns

A non-negative integer.

Examples

% dict size {a 1 b 2}
2

% dict size {a 1 a 2}
1

% dict size {}
0

Errors

% dict size {a}
missing value to go with key
-errorcode NONE

% dict size
wrong # args: should be "dict size dictionary"
-errorcode TCL WRONGARGS

Facts

Capability
None.
Tcl release
Tcl 9.1 and 8.6.
Since
ztcl 1.0.0-beta.1

See also