The while loop

The while loop executes a block of code until a condition is met. Swift provides two forms of the while loop; these are the while and repeat-while loops. In Swift 2.0, Apple replaced the do-while loop with the repeat-while loop. The repeat-while loop functions in the same way as the do-while loop did. Swift uses the do statement for error handling.

We use while loops when the number of iterations to perform is not known and usually dependent on some business logic. A while loop is used when you want to run a loop zero or more times, while a repeat-while loop is used when you want to run the loop one or more times.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset