Content deleted Content added
m →Conditional assignment: <code>?:</code> is most frequently used in conditional assignment statements. |
m →?: in style guidelines: {{fact}} |
||
Line 64:
===?: in style guidelines===
Some corporate programming guidelines list the use of the ternary operator as bad practice because it can harm readability and long-term maintainability.{{fact}} However, when properly crafted the ternary operator is no more difficult to debug than the <code>if</code> statement equivalent (and in fact shouldn't require any debugging at all).{{fact}} Ternary operators are widely used and can be useful in certain circumstances to avoid the use of an <code>if</code> statement, either because the extra verbiage would be too lengthy or because the syntactic context does not permit a statement. For example:
[[C preprocessor|#define]] MAX(a, b) (((a)>(b))? (a): (b))
|