On 01/18/2013 01:13 PM, monarch_dodra wrote:
...
*Personally*, I prefer
if ((a == b) && (c != d))
over
if (a == b && c != d)
I *know* the precedence here, but I still find it clearer with grouping.
HOWEVER, I 100% agree that in such code, the format chosen is very very
important. Place spaces in the wrong spots:
if ( ( a == b ) && ( c != d ) )
And the eyes begin to bleed...
if(a==b && c!=d)
As a side note, I've taken to ALWAYS placing parenthesis with ternary
operators. That thing has some nasty precedence rules...
auto a = b && x ? c :
d || y ? e :
f ^ z ? g :
h ;