O'Reilly logo

Swift Functional Programming - Second Edition by Dr. Fatih Nayebi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required