title: Get Index of Array containing Structs by searching for Struct Value using Swift 3.0
body: <p>I have a struct for holding data;</p>
  
  <pre><code>struct MyStruct {
    var age: Int
    var name: String
  }
  </code></pre>
  
  <p>I make an array of this and fill it with data;</p>
  
  <pre><code>var myArray = [MyStruct]()
  myArray[0] = MyStruct(age: 26, name: "John")
  myArray[1] = MyStruct(age: 35, name: "Smith")
  </code></pre>
  
  <p>How can I find the index of the element in <code>myArray</code> that contains the name "Smith"?</p>
  
  <p>Edit: Here's more context about where I need to find the location using the new code from Losiowaty;</p>
  
  <pre><code>func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -&gt; [UITableViewRowAction]? {
    let selection = tableView.cellForRow(at: indexPath)?.textLabel
    let name = selection!.text!
    let location = myArray.index(where: { $0.name == name})
  
    //additional code to comply with the function and return, unneeded for this context
  }
  </code></pre>