Creating a dictionary

To create a dictionary, we will utilize the create option. The syntax is as follows:

	dict create key value… key value… key value…

How to do it…

In the following example, we will create a dictionary containing a key/value pair. Return values from the commands are provided for clarity. Enter the following command:


% dict create 1 John
1 John

How it works…

The dict create command creates a new dictionary that contains each of the key and value mappings that follow.

There's more…

By adding additional key/value pairs on the command line, you can store numerous entries simultaneously. In the following example, we will expand our dictionary by storing multiple key/value pairs. Return values from the commands are provided for clarity. ...

Get Tcl/Tk 8.5 Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.