0

Project which compiles fine in Xcode 8.3.2 shows many compilation errors around comparing optional/non optional value with ==

What I have found is an older proposal for removing coparison <> for the same: https://github.com/apple/swift-evolution/blob/master/proposals/0121-remove-optional-comparison-operators.md

So now in Xcode 9, I can not even compare two optionals:

    let xxx: String? =  "A"
    let yyy: String? = "B"

    if xxx == yyy { //ERROR: Ambiguous use of operator '=='

    }

Could someone point me to a resource where this would be explained? Or is it just a temporary bug?

Thanks

ds77
  • 107
  • 1
  • 6

1 Answers1

0

Using XCode 9 beta (9M136h) and Swift 4, your instruction compiles.

Variants of == and != which accept optional operands are still useful, and their results unsurprising, so they will remain.

Remove the versions of <, <=, >, and >= which accept optional operands.

So your instruction should works either in Swift 3.2 or Swift 4. Check the swift version you are using in the build settings -> Swift Language Version.

Fares Benhamouda
  • 589
  • 8
  • 21
  • Sorry, my fault. There was a hidden extension overriding operator == for some type of objects. The fact is, Xcode 8 compiled the code fine, while Xcode 9 Swift 3.2 was confused. – ds77 Jul 26 '17 at 12:39