目录

continue statement

Swift 4中的continue语句告诉循环停止它正在做什么,并在循环的下一次迭代开始时再次启动。

对于for循环, continue语句会导致条件测试并增加循环部分的执行。 对于whiledo...while循环, continue语句使程序控制传递给条件测试。

语法 (Syntax)

Swift 4中continue语句的语法如下 -

continue

流程图 (Flow Diagram)

继续声明

例子 (Example)

var index = 10
repeat {
   index = index + 1
   if( index == 15 ){
      continue
   }
   print( "Value of index is \(index)")
} while index < 20

编译并执行上述代码时,会产生以下结果 -

Value of index is 11
Value of index is 12
Value of index is 13
Value of index is 14
Value of index is 16
Value of index is 17
Value of index is 18
Value of index is 19
Value of index is 20
↑回到顶部↑
WIKI教程 @2018