Appending to an existing record

To append data to an existing value Tcl provides the dict lappend command. The syntax is as follows:

	dict lappend name key value…

How to do it…

In the following example, we will create a dictionary containing a collection of key/value pairs and then using the dict lappend command we will append items to the key referenced. Return values from the commands are provided for clarity. Enter the following command:


% set test [dict create 1 1 2 2 3 3]
1 1 2 2 3 3

% dict lappend test 2 more
1 1 2 {2 more} 3 3

How it works…

The dict lappend command appends the data stored in value for the key referenced in key for the dictionary specified in name.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.50.156