//: Playground - noun: a place where people can play
import UIKit
//条件为真会一直循环
//while后面的()可以省略
//while后面的判断没有非0,非空,即真
var a = 10;
while a>0 {
print("真");
a = a-1;
}
//swift中do while 循环需要写成 repeat while
//先执行一次,在根据条件判断,是否进行循环
repeat {
print("假")
a=a-1;
}while a > 10;
网友评论