3 stupid and wrong ways of formatting conditionals (and One Right Way)
// WRONG!
if ( foo == bar || bar == baz || baz == quux ) {
// code here
}
// WRONG!
if ( foo == bar
|| bar == baz
|| baz == quux ) {
// code here
}
// WRONG!
if ( foo == bar
|| bar == baz
|| baz == quux )
{
// code here
}
// CORRECT
if (
( foo == bar )
|| ( bar == baz )
|| ( baz == quux )
) {
// code here
}
Comments