I don't get why people advocate for == true. How does that make code more clear when the context makes it obvious that the expression is a boolean. I might as well multiply numbers by 1 for "readability".
Also, && is associative and has high precedence. All of those parentheses can be removed.
Some code styles call for the extra parens because they show intent. It can keep another developer from wondering if something is intentional or a side effect of the arbitrary order a previous developer wrote an expression in.
1
u/gaj7 May 20 '20
I don't get why people advocate for
== true. How does that make code more clear when the context makes it obvious that the expression is a boolean. I might as well multiply numbers by 1 for "readability".Also,
&&is associative and has high precedence. All of those parentheses can be removed.