It's not uncommon to see the ?: operator being used as a control construct although it's originally defined as an operator:
if (con) {
clause 1;
} else {
clause 2;
}
with ?: as control construct can be written as:
con ? clause 1 : clause2;
It's correct, grammatically & technically and much more compact, compared to the if-else idiom. However it's not the way
this operator is supposed to be used.
网友评论