Swift
break
statement immediately ends the execution of the entire control flow.
If you are using a nested loop (that is, one loop is nested within another loop) Swift Flow chart: The output of the above program execution is as follows:
break
statement stops executing the innermost loop and then starts executing the next line of code after the block. 9.22.1. Grammar #
break
the syntax format of the statement is as follows:break

9.22.2. Example #
import Cocoa
var index = 10
repeat{
index = index + 1
if( index == 15 ){ // Terminate loop when index equals 15
break
}
print( "The value of index is \(index)")
}while index < 20
The value of index is 11
The value of index is 12
The value of index is 13
The value of index is 14