Fork me on GitHub
TypeName TernaryOperatorAnalyzer (return)
Check Id CC0013
Category Style
Severity Warning

Cause

If-else statements can be changed to ternary operators.

Example

var something = true;
if (something)
    return 1;
else
    return 2;

Code fix

A code fix will be presented to you that will transform the code:

var something = true;
return something ? 1 : 2;

Code fix

Related rules

  • CC0014 - Use ternary operator (assignment)

See also

TBD