What are the benefits and drawbacks of the ?: operator as opposed to the standard if-else statement. The obvious ones being:
Conditional ?: Operator
I usually choose a ternary operator when I'd have a lot of duplicate code otherwise.
if (a > 0) answer = compute(a, b, c, d, e); else answer = compute(-a, b, c, d, e);
With a ternary operator, this could be accomplished with the following.
answer = compute(a > 0 ? a : -a, b, c, d, e);