title: Check if Swift array contains instance of object
body: <p>How does one check if a Swift array contains a particular instance of an object? Consider this simple example:</p>
  
  <pre><code>class Car {}
  
  let mazda = Car()
  let toyata = Car()
  
  let myCars = [mazda, toyata]
  
  myCars.contains(mazda) // ERROR!
  </code></pre>
  
  <p>My investigations have let me to the conclusion that the <code>Car</code> class must adopt the <code>Equatable</code> protocol. It seems to be the case:</p>
  
  <pre><code>class Car: Equatable {
      static func ==(lhs: Car, rhs: Car) -&gt; Bool {
          return true
      }
  }
  </code></pre>
  
  <p>Then <code>myCars.contains(mazda)</code> does indeed return <code>true</code>.</p>
  
  <p>However, the implementation of <code>==</code> is obviously not what I want. What I really want it to return is the answer to the question: Are <code>lhs</code> and <code>rhs</code> the same <code>Car</code> instances?</p>
  
  <p>Is it really that complicated?</p>
  
  <p>Thanks!</p>