index = index + 1 }while index < 20 When the above code is executed, it produces the following result: Value of index is 10 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
Loop Control Statements Loop control statements change execution from its normal sequence. When execution leaves a scope, all automatic objects that were created in that scope are destroyed. Swift supports the following control statements. Click the following links to check their detail. Control Statement
This statement tells a loop to stop what it is doing and start again at the beginning of the next iteration through the loop.
Terminates the loop statement and transfers execution to the statement immediately following the loop.
The fallthrough statement simulates the behavior of swift switch to C-style switch.
Swift â€“ continue Statement The continue statement in Swift tells a loop to stop what it is doing and start again at the beginning of the next iteration through the loop. For a for loop, the continue statement causes the conditional test and increments the portions of the loop to execute. For while and do...while loops, the continue statement causes the program control to pass to the conditional tests. 49
Published on Nov 30, 2016