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

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

技术教程推荐

技术领导力实战笔记 -〔TGO鲲鹏会〕

数据结构与算法之美 -〔王争〕

10x程序员工作法 -〔郑晔〕

从0开始做增长 -〔刘津〕

RPC实战与核心原理 -〔何小锋〕

Django快速开发实战 -〔吕召刚〕

说透元宇宙 -〔方军〕

结构沟通力 -〔李忠秋〕

云时代的JVM原理与实战 -〔康杨〕

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