Kotlin 带有 OR 的多个条件

问题描述 投票:0回答:1

我有一个“if”语句,有两个条件。如果只有一个条件不相等,那么它应该显示如下所示的特定文本:

if (food != apple || food != orange ) {
    Text (text = "They are vegetables.")
}    
kotlin if-statement conditional-statements android-jetpack-compose case
1个回答
0
投票

正确答案是: if (food != apple && food != Orange ) { 文本(文本=“它们是蔬菜。”)}

© www.soinside.com 2019 - 2024. All rights reserved.