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. Enter the following command:
% dict create 1 John 2 Mary 3 Paul 1 John 2 Mary 3 Paul
As you can see, the dict create
command accepted the arguments and created a dictionary containing our three key/value pairs. Care should be taken that the key names...