scala的if条件and
在Scala中,使用&&操作符来表示逻辑与(and)关系。
示例:
val x = 10
val y = 5
if (x > 0 && y > 0) {
println("Both x and y are greater than 0")
} else {
println("Either x or y is not greater than 0")
}
在上面的示例中,如果x和y都大于0,则会打印"Both x and y are greater than 0",否则会打印"Either x or y is not greater than 0"。
原文地址: https://www.cveoy.top/t/topic/hQ24 著作权归作者所有。请勿转载和采集!