Swift Continue statement


Release date:2023-11-29 Update date:2023-12-08 Editor:admin View counts:119

Label:

Swift Continue statement

Swift continue statement tells a loop body to stop this loop iteration immediately and restart the next loop iteration.

For for cycle continue the self-adding statement is still executedafter the statement is executed. For while and do...while cycle continue statement to re-execute the conditional judgment statement.

Grammar

Swift continue the syntax format of the statement is as follows:

continue

Flow chart:

Image0

Example

import Cocoa

var index = 10

repeat{
   index = index + 1

   if( index == 15 ){ // Skip when index equals 15
      continue
   }
   print( "The value of index is \(index)")
}while index < 20

The output of the above program execution is as follows:

The value of index is 11
The value of index is 12
The value of index is 13
The value of index is 14
The value of index is 16
The value of index is 17
The value of index is 18
The value of index is 19
The value of index is 20

Powered by TorCMS (https://github.com/bukun/TorCMS).