- Swift Functional Programming(Second Edition)
- Dr. Fatih Nayebi
- 82字
- 2021-07-02 23:54:26
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.