This sample code on Xcode 6.3 ...
var str1 = ""
var str2 = ""
if str1.isEmpty ^ str2.isEmpty {
// do something.
}
displays the following error.
'^' is unavailable: use the '!=' operator instead
I cannot find the spec in Apple documentation. Is this specification (and I'll have to lump it)?
Assuming you are trying to use a logical XOR, a !=
should serve your purpose. The ^
is a bitwise XOR. So makes sense that Apple removed it for bool values.
It's clearly intentional:
$ echo ':print_module Swift' | swift -deprecated-integrated-repl | fgrep "use the '!=' operator instead"
shows:
@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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With