Reputation: 5907
I am trying to accomplish something very simple in TCL. Namely string concatenation where some (not all) of the strings are assigned to variables. For example
set string1 fragilistic
set string2 docious
puts [concat supercali $string1 expiali $string 2]
this results in supercali fragilistic expiali docious
. I really dont want those spaces in between so what I tried to do was
puts [concat supercali$string1expiali$string 2]
But this will return an error. How can I concatenate strings with strings assigned to variables in TCL without those intermediate spaces?
Upvotes: 1
Views: 3682
Reputation: 137767
You've got two options. The classic Tcl way of doing things is this, with brace-delimited variable names:
puts supercali${string1}expiali${string2}
From Tcl 8.6 onwards, there's also the command string cat
(which was introduced to make lmap
work better):
puts [string cat supercali $string1 expiali $string2]
Low-level behaviour should be identical.
Upvotes: 3