Control Flow Statements
Continue, Break statements
Syntax
Continue Statement
Skips the current iteration of a loop and continues with the next iteration.
continueExample:
var a = 0
while a < 10{
if a == 5 {
continue
}
print(string(a))
}
// 0 1 2 3 4 6 7 9Break Statement
Terminates the loop statement and transfers control to the statement immediately following the loop.
breakExample:
var a = 0
while a < 10{
if a == 5{
break
}
print(string(a))
}
// 0 1 2 3 4