tcl脚本学习四: [] ,“” ,{} 的学习以及嵌套使用

lesson 4

1. set x "abc"
puts "A simple substitution: $x "
//简单的例子

2. set y [set x "def"]
puts "Remember that set returns the new value of the variable: X: $x Y: $y "
//当使用[]的时候,会将 []内的返回值作为y所定义的值

3. set z {[set x "This is a string within quotes within braces"]}
puts "Note the curly braces: $z "
//这是括号中引号中的字符串

4. set a "[set x {This is a string within braces within quotes}]"
puts "See how the set is executed: $a"
puts "$x is: $x "
//此时x和a的值均为那个字符串

5.set b "[set y {This is a string within braces within quotes}]"
puts "Note the \ escapes the bracket: $b is: $b"
puts "$y is: $y"
//特别注意:!! []将不对[]内进行赋值等一系列操作,直接原封不动作为输出给b

原文地址:https://www.cnblogs.com/gold-life/p/5731117.html