While the dict for
command is generally used for processing multiple key/value pairs, Tcl provides the dict get
command to obtain the value assigned to a specific key. The syntax is as follows:
dict get dictionaryValue key
In the following example, we will create a dictionary containing a set of key/value pairs and then, using the dict get
command, obtain the value associated with the specified key. Return values from the commands are provided for clarity. Enter the following command:
% set names [dict create 1 John 2 Mary 3 Paul]
1 John 2 Mary 3 Paul
% dict get $names 3
Paul
3.143.5.201