RosettaCodeData/Task/Associative-array-Creation/Tcl/associative-array-creation-2.tcl
2023-07-01 13:44:08 -04:00

20 lines
361 B
Tcl

# Create in bulk
set d [dict create foo 5 bar 10 baz 15]
# Create/update one element
dict set d foo 5
# Access one value
set value [dict get $d foo]
# Output all values
dict for {key value} $d {
puts $value
}
# Alternatively...
foreach value [dict values $d] {
puts $value
}
# Output the whole dictionary (since it is a Tcl value itself)
puts $d