Xcode 6.3 上的此示例代码...
var str1 = ""
var str2 = ""
if str1.isEmpty ^ str2.isEmpty {
// do something.
}
显示以下错误。
'^' is unavailable: use the '!=' operator instead
我在 Apple 文档中找不到规范。是这个规范吗(我不得不把它混为一谈)?
假设您正在尝试使用逻辑 XOR,a!=
应该可以满足您的目的。是^
按位异或。因此,Apple 将其删除为 bool 值是有道理的。
这显然是故意的:
$ echo ':print_module Swift' | swift -deprecated-integrated-repl | fgrep "use the '!=' operator instead"
显示:
@availability(*, unavailable, message="use the '!=' operator instead") func ^=(inout lhs: Bool, rhs: Bool)
@availability(*, unavailable, message="use the '!=' operator instead") func ^(lhs: Bool, rhs: Bool) -> Bool