107
Break Statement
Swift 4 break statement is used in two cases:
- The break statement is used within a loop when you have toimmediately terminatea statement. The program control resumes at the next statement following the loop.
- It is also used to terminate a case in switch statement.
In the case of nested loops, the break statement terminates the inner most loop andstart executing the next line of the code after the block.
Syntax:
The syntax of Swift 4 break statement is:
Flow diagram of Swift 4 break Statement
Example:
Output:
Value of index is 11 Value of index is 12 Value of index is 13 Value of index is 14 Value of index is 15 Value of index is 16 Value of index is 17 Value of index is 18 Value of index is 19 Value of index is 20 Value of index is 21 Value of index is 22 Value of index is 23 Value of index is 24
Next TopicContinue Statement