小编Ter*_*ceW的帖子

为"If"语句测试值设置多个整数

我试图在if语句中为单个变量设置多个整数测试.逻辑运算符不会起作用,因为它们必须是布尔值.

例如:

if self.nodeAtPoint(location) == self.fake {
    groundspeed = 35.0
    self.button1value++

    if(button1value == 2) {
      groundspeed = 5.0
    }

    if(button1value == 4){
        groundspeed = 5.0
    }

    if(button1value == 6) {
        groundspeed = 5.0
    }
}
Run Code Online (Sandbox Code Playgroud)

目标是能够将所有偶数显示在一个if语句中.

if-statement logical-operators swift

10
推荐指数
3
解决办法
2188
查看次数

标签 统计

if-statement ×1

logical-operators ×1

swift ×1