4 ms·
No, not always. Not in Go, or in Rust, or Ruby, for example. The assumption being in these languages that if is followed by an expression and that expression is
by Udo 11y ago
No, not always. Not in Go, or in Rust, or Ruby, for example. The assumption being in these languages that if is followed by an expression and that expression is parsed to its natural end anyway - but this only works if the syntax allows for that end to be found without ambiguity.
- krylon 11y agoIn Go, however, go fmt will remove the unnecessary parentheses. I was very annoyed at first, when I saw this, but I got used to it.
- mcguire 11y agoDoes it generally do this in expressions, based on operator precedence, or is it limited to the outer parentheses on selected statements?
- krylon 11y agoI am not an expert, but I think it only removes the outermost ones. The major task of the tools is indentation and placement of curly braces.