For the if...else statement below
if (a > b) {
max = a;
}
else {
max = b;
}
will result shortcut as below?
max = (a > b) ? a : b;
What about this if and nested if statement?
if (a > b) {
max = a;
}
else {
if (c > d)
max = c;
else
max = d;
}
Just do:
And this can be formatted to be arbitrarily long, so the formatting is important because ternary operators can get real confusing real fast. Consider:
Verses: