Tcl : Creating Array

Tcl array can be created by set command by specifying its key to array name.

From example above we define array named days with keys containing numbers and text values. If we try to do variable substitution with $days, it wont work. If we do variable substitution with key specified then it will work.

We can have text as array’s key. Tcl array is an associative array.

From sample above we know that a text key is case sensitive (ID is different with id).

Another way to create array is with array set command by passing list of key value pairs as 3rd parameter and array name as 2nd parameter.

Thats all how we create array in Tcl. Bye!

Leave a Reply

Your email address will not be published. Required fields are marked *