For is the only loop in Go.
- 3 parts as usual in Go:
- init statement
- condition expression
- post statement
- But no ( ) surrounding the statements
- The init and post statements are optional:
Using for as while
Instead of using while
one can use for
almost in the same way:
Infinite loops
Next Chapter: Arrays and slices