Swift 中的 repeat...while 循环函数

首页 / Swift入门教程 / Swift 中的 repeat...while 循环函数

repeat.while循环类似于while循环,不同之处在于保证至少执行一次repeat.while循环。

repeat...while - 语法

SWIFT 4中repeat.while循环语法为-

repeat {
   statement(s);
} 
while( condition );

repeat...while - 流程图

Repeat-While Loops

repeat...while - 示例

var index=10

repeat {
   print( "Value of index is\(index)")
   index=index + 1
}
while index < 20

执行上述代码时,将生成以下结果-

无涯教程网

Value of index is 10
Value of index is 11
Value of index is 12
Value of index is 13
Value of index is 14
Value of index is 15
Value of index is 16
Value of index is 17
Value of index is 18
Value of index is 19

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

技术教程推荐

零基础学Python -〔尹会生〕

Spring Boot与Kubernetes云原生微服务实践 -〔杨波〕

Go 并发编程实战课 -〔晁岳攀(鸟窝)〕

说透5G -〔杨四昌〕

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

Spring Cloud 微服务项目实战 -〔姚秋辰(姚半仙)〕

深入浅出分布式技术原理 -〔陈现麟〕

人人都用得上的数字化思维课 -〔付晓岩〕

Serverless进阶实战课 -〔静远〕

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