CCoding Style - Be Clear3
Be Clear ...
The ?: operator is fine for short expressions where it can replace four lines of if-else with one, as in
max = ( a > b ) ? a : b;
- Clarity is not the same as Brevity
Often the clearer code will be shorter, as in the bit-shifting example, but it can also be longer; as in the conditional expression recast as if-else.
- The proper criterion is ease of understanding.