Q & A tcl - quotation mark key
The character " is special for the Tcl parser at the beginning of a word (or, of course, a word starting with " ). In fact, if you put spaces, you would get the error:
% set foo("bar") 2 wrong # args: should be "set varName ?newValue?" In the case when you make calls to string length , " is at the beginning of the word, so it is special. If we add an extra start character, we will see that the feature " disappears:
% string length x"bar" 6 If you are doing something complicated with array indexes, I think itβs usually easier to put the element name in a variable, since then it becomes clearer what is happening (and it is usually easier to debug):
set idx "bar" set foo($idx) 12