nested switch - 语法
switch switchingString { matchString1 { body1 switch switchingString { matchString1 { body1 } matchString2 { body2 } ... matchStringn { bodyn } } } matchString2 { body2 } ... matchStringn { bodyn } }
nested switch - 示例
#!/usr/bin/tclsh set a 100 set b 200 switch $a { 100 { puts "This is part of outer switch" switch $b { 200 { puts "This is part of inner switch!" } } } } puts "Exact value of a is : $a" puts "Exact value of a is : $b"
编译并执行上述代码后,将产生以下输出-
This is part of outer switch This is part of inner switch! Exact value of a is : 100 Exact value of a is : 200
参考链接
https://www.learnfk.com/tcl-tk/tcl-nested-switch-statements.html