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

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

无涯教程网

链接:https://www.learnfk.comhttps://www.learnfk.com/swift/swift-repeat-while-loop.html

来源:LearnFk无涯教程网

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

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

技术教程推荐

Nginx核心知识150讲 -〔陶辉〕

程序员的数学基础课 -〔黄申〕

OpenResty从入门到实战 -〔温铭〕

Swift核心技术与实战 -〔张杰〕

说透中台 -〔王健〕

Vim 实用技巧必知必会 -〔吴咏炜〕

代码之丑 -〔郑晔〕

PyTorch深度学习实战 -〔方远〕

Go进阶 · 分布式爬虫实战 -〔郑建勋〕

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