Swift BasicsLesson 17Free preview
Swift While Loop
This lesson is part of Swift · All levels
Summary
This lesson discusses the whilst and repeat-while repetitions in Swift. Repetition while evaluates the condition before the instruction block is executed, whereas repeat-while (similar to do-while in other languages) executes the code block at least once before the condition is checked at the end of the iteration.
Key points
- The repetition of 'while (condition) ' runs repeatedly during the value of the condition.
- Repeat-while code runs before evaluating the condition
- The keyword 'repeat' replaced the traditional keyword 'do' to avoid confusion with do-catch error handling
- Supports the keywords 'break' and 'continue' for loop loop diversion
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.