title: Bug with equals operator and NSObjects in Swift 2.0?
body: <p>Ok, something strange is happening when writing your own equals operator for NSObject subclasses in Swift 2.0 like this:</p>
  
  <pre><code>func ==(lhs: MyObject, rhs: MyObject) -&gt; Bool {
      return lhs.identifier == rhs.identifier
  }
  </code></pre>
  
  <p>For a class that looks like this:</p>
  
  <pre><code>class MyObject: NSObject {
      let identifier: String
      init(identifier: String) {
          self.identifier = identifier
      }
  }
  </code></pre>
  
  <p>This used to work just fine in Swift 1.2 and below. It still kind of works:</p>
  
  <pre><code>let myObject1 = MyObject(identifier: "A")
  let myObject2 = MyObject(identifier: "A")
  let result = (myObject1 == myObject2)
  // result is true
  </code></pre>
  
  <p>So far so good, but what if both of the variables were optionals?</p>
  
  <pre><code>let myObject1: MyObject? = MyObject(identifier: "A")
  let myObject2: MyObject? = MyObject(identifier: "A")
  let result = (myObject1 == myObject2)
  // result is false, equals operator was never even called
  </code></pre>
  
  <p>And one other thing that no longer works:</p>
  
  <pre><code>let myObject1 = MyObject(identifier: "A")
  let myObject2 = MyObject(identifier: "A")
  let result = (myObject1 == myObject2)
  // result is true
  let result = (myObject1 != myObject2)
  // result is true, equals operator was never even called
  </code></pre>
  
  <p>So apparently, != no longer calls the == operator and negates it. It seems to just compare the instances instead when using !=</p>
  
  <p>All of this only happens when your class is a subclass of NSObject (directly or indirectly). When it's not, everything works just like you would expect.</p>
  
  <p>Can anyone tell me if this is a new 'feature' in Swift 2.0 or just a nasty bug?</p>