Tcl provides a simple method for incrementing a value stored within a dictionary with the dict incr
command. This is extremely useful when storing numeric values in the dictionary. The syntax is as follows:
dict incr dictionaryValue key increment
In the following example, we will create a dictionary containing a key/value pair and then using the dict incr
command, we will increase the value associated with the key specified. Return values from the commands are provided for clarity. Enter the following command:
% set numbers [dict create one 1]
one 1
% dict incr $numbers one 3
one 4
13.58.120.57