Go - Flow

Card Puncher Data Processing

Boolean Control-flow statements

  • if
  • switch (multi-way branch)

Control statements may include an optional simple statement:

  • a short variable declaration,
  • an increment
  • or assignment statement,
  • or a function call

Break and continue

The break and continue statements modify the flow of control.

  • A break causes control to resume at the next statement after the innermost for, switch, or select statement.
  • A continue causes the innermost for loop to start its next iteration.

Statements may be labeled so that break and continue can refer to them, for instance to break out of several nested loops at once or to start the next iteration of the outermost loop. There is even a goto statement, though it’s intended for machine-generated code, not regular use by programmers.

List

Switch

switch coinflip() {
case "heads":
	heads++
case "tails":
	tails++
default:
	fmt.Println(" landed on edge!")
}

Documentation / Reference







Share this page:
Follow us:
Task Runner