Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
只是一个简单但经常需要的操作 - 如何将字符串添加到变量:
set s "world!!!" prepend s "Hello " #how to accomplish this effectively? puts $s #should print "Hello world!!!"
你可以写一个程序prepend:
prepend
proc prepend {s_var txt} { upvar 1 $s_var s set s "${txt}${s}" }
这正是你想要的。但我认为通常写起来更简单:
set s "Hello ${s}"
自从我使用 TCL 已经有一段时间了,但是你有没有试过这个:
set s "world!" set s "hello $s" puts $s