title: Create Set of Array in Swift
body: <p>I was trying to create a <strong>set</strong> out of an <strong>array</strong> to make elements unique.
  I thought it would be an elegant approach to use the Set initializer to do this job. So I created an <strong>array</strong> and tried to initialize my new <strong>set</strong> using that array.
  But the compiler was complaining. I tried it using Integer values and it works like a charm. But with my own class it does not work. I also thought that the <code>Equatable Protocol</code> is the right way to go .. but as you see, it does not solve my Problem.</p>
  
  <p>Consider the following Playground:</p>
  
  <pre><code> import UIKit
  
  internal struct Object: Equatable {
      var a: Int
  }
  
  internal func == (lhs:Object,rhs: Object) -&gt; Bool {
      return lhs.a == rhs.a
  }
  
  let array = [Object(a:1),Object(a:1),Object(a:1),Object(a:1),Object(a:2)]
  
  let set = Set(array) // ERROR
  </code></pre>
  
  <p>The Compiler is complaining with </p>
  
  <blockquote>
    <p>can not invoke initializer Set&lt;_> with argument of type [Object]</p>
  </blockquote>
  
  <p>Which Protocol do I need to implement to makes things work?</p>