title: Shorthand to test if an object exists in an array for Swift?
body: <p>Currently, I have an array of objects like this:</p>
  
  <pre><code>var myArr = [
    MyObject(name: "Abc", description: "Lorem ipsum 1."),
    MyObject(name: "Def", description: "Lorem ipsum 2."),
    MyObject(name: "Xyz", description: "Lorem ipsum 3.")
  ]
  </code></pre>
  
  <p>I am testing if an object exists before proceeding like this:</p>
  
  <pre><code>let item = myArr.filter { $0.name == "Def" }.first
  if item != nil {
    // Do something...
  }
  </code></pre>
  
  <p>But I'm looking for a shorter way to do this since I am doing this a lot. I'd like to do something like this but it is invalid:</p>
  
  <pre><code>if myArr.contains { $0.name == "Def" } {
    // Do something...
  }
  </code></pre>
  
  <p>Is there any shorthand syntax I'm missing or a better way to do this?</p>