3 ms·
The same-line convention comes from automatic semicolon insertion at the end of lines. A semicolon is inserted if the line ends with "}", but not "{"... hence,
by mratzloff 14y ago
The same-line convention comes from automatic semicolon insertion at the end of lines. A semicolon is inserted if the line ends with "}", but not "{"... hence, "} else {". This is also the reason multi-line lists require a trailing comma.
- shadowmint 14y agoThe syntax is pretty explicit in not inserting the ';' after some characters; eg. '.' (which is why you can go: blah.Go(). Go(). Go() Which is equivalent to: blah.Go().Go().Go() I don't see why it would be significantly breaking to allow a } to similarly avoid the automatically inserted semicolon for if statements. This wasn't a 'consequence'; this was a design decision.
- _ak 14y ago> This wasn't a 'consequence'; this was a design decision. A design decision with a sound reasoning: https://groups.google.com/forum/?fromgroups=#!topic/golang-nuts/XuMrWI0Q8uk https://groups.google.com/forum/?fromgroups=#!topic/golang-n...
- kyrias 14y agoIt's not the only reason. You can also just comment out some lines and it will still work just fine.