This command performs one of several operations on the variable given by arrayName. Unless otherwise specified for individual commands below, arrayName must be the name of an existing array variable. The option argument determines what action is carried out by the command. The legal options (which may be abbreviated) are:
array set colorcount {
red 1
green 5
blue 4
white 9
}
foreach {color count} [array get colorcount] {
puts "Color: $color Count: $count"
}
=> Color: blue Count: 4
Color: white Count: 9
Color: green Count: 5
Color: red Count: 1
foreach color [array names colorcount] {
puts "Color: $color Count: $colorcount($color)"
}
=> Color: blue Count: 4
Color: white Count: 9
Color: green Count: 5
Color: red Count: 1
foreach color [lsort [array names colorcount]] {
puts "Color: $color Count: $colorcount($color)"
}
=> Color: blue Count: 4
Color: green Count: 5
Color: red Count: 1
Color: white Count: 9
array statistics colorcount
=> 4 entries in table, 4 buckets
number of buckets with 0 entries: 1
number of buckets with 1 entries: 2
number of buckets with 2 entries: 1
number of buckets with 3 entries: 0
number of buckets with 4 entries: 0
number of buckets with 5 entries: 0
number of buckets with 6 entries: 0
number of buckets with 7 entries: 0
number of buckets with 8 entries: 0
number of buckets with 9 entries: 0
number of buckets with 10 or more entries: 0
average search distance for entry: 1.2