我正在尝试实现两个选项值之间的切换:
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?)'
我对你们的问题是,我怎样才能设法生成这与可选值之间的案例?
我会非常感谢你的帮助