Open wn2owg opened 5 years ago
Interesting observation. I think you're right. If I read
Go's if statements are like its for loops; the expression need not be surrounded by parentheses ( )
I would deduce that "the expression need not be surrounded by parentheses" also holds for for
loops, but "need not" is misleading in that case since you cannot use ( )
in the loop condition.
Should I send a PR with a fix like this
the
if
expression need not be surrounded by parentheses ( ) but the braces { } are required.
It won't be misleading and can provide clear and concise statement.
Context: https://tour.golang.org/flowcontrol/5
on 5/14 of if, text says parens are NEED NOT. sure enough if (x>1) or if x>1 both work which IS what the text implies
so on for 1/14 the text IMPIES no parens but cutely braces required, so for fun tried them like the if
for (i:=1; i<10;i+1 ) but this FAILS with syntax error.
I was surprised because of "if" behavior, but also the texts implication.
Bill