array get
Gives the names and the values of the elements of an array as a list.
array get ARRAYNAME ?PATTERN?
Description
Gives a list with the name and the value of each element, in the order in which the elements were made. With PATTERN, the list has only the elements whose names match the glob pattern, with the rules of string match.
A variable that is not an array, and a name with no variable, give an empty list. The list is a valid dict value and a valid LIST of array set.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| ARRAYNAME | variable name | required | The array to read. |
| PATTERN | glob pattern | none | The names of the elements to give. |
Returns
A list of names and values, empty when no element matches.
Examples
% array set g {x 1 y 2 xy 3}; array get g
x 1 y 2 xy 3
% array get g x*
x 1 xy 3
% array get g {[y]}
y 2
% array get nope
% dict get [array get g] y
2
Errors
% array get
wrong # args: should be "array get arrayName ?pattern?"
-errorcode TCL WRONGARGS
% array get g x y
wrong # args: should be "array get arrayName ?pattern?"
-errorcode TCL WRONGARGS
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztcl 1.0.0-beta.1