Swift 中的 continue 语句函数

首页 / Swift入门教程 / Swift 中的 continue 语句函数

SWIFT 4中的Continue语句告诉循环停止它正在做的事情,并在循环的下一次迭代开始时重新开始。

对于for循环,Continue语句导致条件测试并递增要执行的循环部分,对于While和Do.While循环,Continue语句使程序控制传递给条件测试。

continue - 语法

SWIFT 4中Continue语句语法如下所示:-

continue

continue - 流程图

Continue Statement

continue - 示例

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

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

移动端自动化测试实战 -〔思寒〕

JavaScript核心原理解析 -〔周爱民〕

说透芯片 -〔邵巍〕

Redis源码剖析与实战 -〔蒋德钧〕

手把手带你写一门编程语言 -〔宫文学〕

深入剖析Java新特性 -〔范学雷〕

运维监控系统实战笔记 -〔秦晓辉〕

结构写作力 -〔李忠秋〕

超级访谈:对话道哥 -〔吴翰清(道哥)〕

好记忆不如烂笔头。留下您的足迹吧 :)