Go TutorialLesson 13Free preview
Go Conditions
This lesson is part of Go · All levels
Summary
This lesson discusses branching on Go with if and else. The terms in if do not need to be encapsulated, and Go supports the init statement so that the variable can be created and tested simultaneously in a single if block. This branching allows the program to select the blocks of code that are executed based on certain conditions.
Key points
- If in Go without a curtain surrounding the condition
- Go supporting the init statement: if x:= f(); x > 0 {...}
- Else should be on the same line as the closing parenthesis if
- The condition should be a bool, not a number.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.