You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if(true){
// do something
}
else{
// do something else
}
But it isn't the same case with Go , I guess. when i hit enter and add else in next line, it gives syntax error. I initially thought it was just indentation but later realized syntax is supposed to be the way as in this sample. Felt specifying the same would be helpful.
The text was updated successfully, but these errors were encountered:
crisman
added a commit
to crisman/golang_website
that referenced
this issue
May 13, 2023
Many users of the Go Tour trip over using else after a newline which
generates a syntax error that is hard to understand unless the reader is
primed to think about a newline before the else. "tour/flowcontrol/7"
("If and else") the slide that first talks about else seems the right place
to update.
Add statement about required location of else after if block, provide an
invalid else code example mirroring the slide's program, and provide links
to the language spec for details.
Fixesgolang/tour#1481Fixesgolang/tour#1427Fixesgolang/tour#1062Fixesgolang/tour#442
Context: https://tour.golang.org/flowcontrol/7
In javascript or Java, below code doesn't harm:
But it isn't the same case with Go , I guess. when i hit enter and add else in next line, it gives syntax error. I initially thought it was just indentation but later realized syntax is supposed to be the way as in this sample. Felt specifying the same would be helpful.
The text was updated successfully, but these errors were encountered: