Swift BasicsLesson 19Free preview
Swift Break/Continue
This lesson is part of Swift · All levels
Summary
This lesson discusses the break, continue, and use of labeled statements in Swift. Repeat labels allow developers to name identifiers to the external loop, so the break or continue command can specifically target a particular loop in a nested loop structure.
Key points
- The keyword 'break' stops the execution of the nearest repetition for a moment.
- The keyword 'continue' stops the current iteration and immediately moves on to the next iteration.
- The labelled statements are written with the label name followed by the colon before the loop keyword: 'Loop name: for...'
- The 'break name loop' syntax stops the external repetition precisely from within the nested loop
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.