title: Swift arrays and contains, how to determine if a collection contains an object or value?
body: <p>I'm at it again with swift arrays and containsObject provided by NSArray only!</p>
  
  <p>I bridge the swift array to NSArray to do that contains:</p>
  
  <pre><code>extension Array {
      func contains(object:AnyObject!) -&gt; Bool {
          if(self.isEmpty) {
              return false
          }
          let array: NSArray = self.bridgeToObjectiveC();
          return array.containsObject(object)
      }
  }
  </code></pre>
  
  <p>it works fine in general but as soon as I put a String! in an array of type String, it crashes. Even though containsObject does take a AnyObject!</p>
  
  <pre><code>        var str : String! = "bla"
          var c = Array&lt;String&gt;();
          c.append(str)
          println(c.contains(str))
  </code></pre>
  
  <p>declaring a String! array also doesn't help</p>
  
  <pre><code>        var str : String! = "bla"
          var c = Array&lt;String!&gt;();
          c.append(str)
          println(c.contains(str))
  </code></pre>
  
  <p>BUT the same without <code>!</code> works fine</p>
  
  <pre><code>        var str : String = "bla"
          var c = Array&lt;String&gt;();
          c.append(str)
          println(c.contains(str))
  </code></pre>
  
  <p>SO how do I explicitly wrap stuff? I don't really see why I'd have to explicitly wrap it only so it is right unwrapped but that's what it looks like.</p>