Download our all in one automation tool for various social media websites.
Continue statement forces the code between current iteration and next iteration to be skipped and program flow resumes on the next iteration.
Continue statement is used for immediately forcing the next iteration in the loop.
Program given below demonstrates how to use continue statement inside a for loop.
package main
import (
"fmt"
)
func main() {
for a := 0; a < 4; a++ {
if a == 2 {
continue
}
fmt.Println("a is:", a)
}
}
Above program produces following output:
a is: 0
a is: 1
a is: 3
Above program makes use of a continue statement inside a for loop. If the condition above the continue statement is met, then continue statement will be executed.
Once continue statement is executed, it forces the code between current iteration and next iteration to be skipped and program flow resumes to the next iteration.