pushisaactivated是可选的bool变量。我用这个代码来检查它的价值

if let pushOn = pushIsActivated {
    if pushOn {
        // Do some stuff...
    }
}

有没有可能做些
if let pushOn = pushIsActivated, pushOn {
    // Do some stuff ...
}


if let pushOn = pushIsActivated && pushOn {
    // Do some stuff ...
}

最佳答案

行应该是:

if let pushOn = pushIsActivated where pushOn {

}

关于swift - 打开值并使用swift在同一行上验证它的内容,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40846376/

10-10 20:51