【问题标题】:Ternary Conditional Operator in kotlin [duplicate]kotlin中的三元条件运算符
【发布时间】:2019-01-18 01:51:17
【问题描述】:

这个表达式在 Kotlin 中的等价物是什么。

a ? b : c

这是给出错误。

【问题讨论】:

标签: kotlin ternary-operator


【解决方案1】:

在 Kotlin 中,if 语句是表达式。所以下面的代码是等价的:

if (a) b else c

希望它对你有用。

【讨论】:

    猜你喜欢
    • 2013-04-26
    • 2023-04-11
    • 1970-01-01
    • 1970-01-01
    • 2020-02-08
    • 2014-10-19
    • 2010-10-20
    • 1970-01-01
    相关资源
    最近更新 更多