TCL continue语句

Tcl语言中continue语句的工作有点像break语句。但不是强制终止,但是,继续强制循环的下一个迭代发生,跳过中间的代码。

对于for循环,continue语句使循环的条件测试和增量部分执行。对于while循环,continue语句通过程序控制的条件测试。

语法

在Tcl continue语句的语法如下:

continue;

流程图

示例

#!/usr/bin/tclsh

set a 10
# do loop execution 
while { $a < 20 } {
   if { $a == 15} {
     #skip the iteration 
	 incr a
     continue
   }
   puts "value of a: $a"
   incr a     
}

当上述代码被编译和执行时,它产生了以下结果:

value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 16
value of a: 17
value of a: 18
value of a: 19
联系我们

邮箱 626512443@qq.com
电话 18611320371(微信)
QQ群 235681453

Copyright © 2015-2022

备案号:京ICP备15003423号-3