WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Go - The continue Statement


The Go continue statement is a bit like a break statement. But continue does not jump out of the loop, but skips the current loop to execute the next loop statement.

In a

for loop, executing a continue statement triggers the execution of the for incremental statement.

Syntax

The

continue syntax is as follows:

continue;

Instance

Skip this loop to execute the next loop when the variable a is equal to 15:

example

package main

import "fmt"

func main() {
   /* Defining local variables */
   var a int = 10

   /* for cycle */
   for a < 20 {
      if a == 15 {
         /* Skip this loop */
         a = a + 1;
         continue;
      }
      fmt.Printf("a Value : %d\n", a);
      a++;    
   }  
}

The above example execution result is:

a Value : 10
a Value : 11
a Value : 12
a Value : 13
a Value : 14
a Value : 16
a Value : 17
a Value : 18
a Value : 19