美文网首页
Concerning the ?: Operator: Is I

Concerning the ?: Operator: Is I

作者: 刘煌旭 | 来源:发表于2020-11-22 12:35 被阅读0次

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.

相关文章

网友评论

      本文标题:Concerning the ?: Operator: Is I

      本文链接:https://www.haomeiwen.com/subject/xwduiktx.html