Branch statements

In many languages, it is possible to change the flow of a loop preemptively with the use of branch statements.

The two branch statements that control a loop are break and continue.

  • break will stop the iteration of the loop and exit it without calling the post condition.
  • continue will skip the rest of the loop and continue to end
for i := 0; i < 10; i++ {
    if i < 5 {
    fmt.println("Called once");
    if i == 5 {
    fmt.println("Never called");

results matching ""

    No results matching ""