【发布时间】:2020-08-15 09:31:36
【问题描述】:
我正在尝试实现两个选项值之间的切换:
import UIKit
var numOne: Int?
var numTwo: Int?
func doSomething() {
switch (numOne, numTwo) {
case (!nil, nil):
print("something")
case (_ == _):
print("equal")
default:
break
}
}
doSomething()
但是我收到了这个错误:
在第一种情况下,我收到此错误:
'nil' is not compatible with expected argument type 'Bool'
在第二种情况下,我遇到了另一个错误:
Expression pattern of type 'Bool' cannot match values of type '(Int?, Int?)'
我对你们的问题是,我怎样才能设法在 this 和可选值之间生成案例?
非常感谢您的帮助
【问题讨论】:
标签: ios swift iphone xcode11.4 swift5.2