Go theorytheory 0/50 · 0%
Fundamentals · easy

5. Control Flow

if, for and switch.

Go has only one loop keyword, `for`, which covers while and infinite loops. `if` supports an init statement, commonly `if err := do(); err != nil`. Switch cases do not fall through by default and can switch on types or on conditions with no subject expression.

Check your understanding

  1. 1. How many loop keywords does Go have?

  2. 2. Do switch cases fall through by default?