Add clarification for else syntax

Rationale: https://github.com/golang/go/issues/5440

else has to be in same line as closing parenthesis. Otherwise people coming from C/C++ would see not so obvious error
This commit is contained in:
Kacper Wikieł 2019-10-03 19:40:43 +02:00 committed by GitHub
parent 82287d9903
commit fbf17474ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,6 +29,8 @@ func main() {
} else {
fmt.Println(num, "has multiple digits")
}
// else has to be in same line as closing parenthesis
// Moving else to the next line would cause a syntax error
}
// Note that you don't need parentheses around conditions