...
While this noncompliant code example compiles correctly, it is unlikely that it means what the author of the code intended.
Code Block | ||||
---|---|---|---|---|
| ||||
int a = 2; int b = 2; int c = 2; /* ... */ if (a < b < c) /* misleading, likely bug */ /* ... */ if (a == b == c) /* misleading, likely bug */ |
...
Treat relational and equality operators as if it were invalid to chain them.
Code Block | ||||
---|---|---|---|---|
| ||||
if ( (a < b) && (b < c) ) /* clearer, and probably what was intended */ /* ... */ if ( (a == b) && (a == c) ) /* ditto */ |
...