Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tour: if vs for info text #743

Open
wn2owg opened this issue Mar 29, 2019 · 2 comments · May be fixed by golang/website#65
Open

tour: if vs for info text #743

wn2owg opened this issue Mar 29, 2019 · 2 comments · May be fixed by golang/website#65
Labels
NeedsFix The path to resolution is known, but the work has not been done.

Comments

@wn2owg
Copy link

wn2owg commented Mar 29, 2019

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

@ALTree
Copy link
Member

ALTree commented Mar 30, 2019

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.

@ALTree ALTree added the NeedsFix The path to resolution is known, but the work has not been done. label Mar 30, 2019
@Abby3017
Copy link

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.

sagar23sj added a commit to sagar23sj/tour that referenced this issue Apr 22, 2021
Existing article is misleading, in new change clear description is provided

Fixes golang#743
sagar23sj added a commit to sagar23sj/tour that referenced this issue May 20, 2021
Existing article is misleading, in new change clear description is provided

Fixes golang#743
sagar23sj added a commit to sagar23sj/website that referenced this issue Jun 15, 2021
Existing article is misleading, in new change clear description is provided.

Fixes: golang/tour#743
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
3 participants