上QQ阅读APP看书,第一时间看更新
while loops
Swift provides while and repeat-while loops. A while or repeat-while loop performs a set of expressions until a condition becomes false. Consider the following example:
var n = 2
while n < 100 {
n = n * 2
}
var m = 2
repeat {
m = m * 2
} while m < 100
The while loop evaluates its condition at the beginning of each iteration. The repeat-while loop evaluates its condition at the end of each iteration.