title: Swift 4 Cannot invoke 'index' with an argument list of type
body: <p>I have a problem with calling the array method <code>index(of:)</code>.
  <code>MyClass</code> inherits from <code>UIViewController</code> and conforms to the <code>MyDelegate</code> protocol.</p>
  
  <pre><code>//self.viewControllers: [(UIViewController &amp; MyDelegate)]
  guard let myController = viewController as? MyClass,
  let index = self.viewControllers.index(of: myController) else {return}
  </code></pre>
  
  <p>then I get the error: </p>
  
  <blockquote>
    <p>Cannot invoke 'index' with an argument list of type '(of: (UIViewController &amp; MyDelegate))'</p>
  </blockquote>
  
  <p>How can I solve this problem and is there a better solution than implementing <code>index(of:)</code> in an extension?</p>
  
  <pre><code>extension Array where Element == (UIViewController &amp; MyDelegate) { 
      func index(of: Element) -&gt; Int? { 
          for i in 0..&lt;self.count { 
              if self[i] == of {
                  return i
              } 
          } 
          return nil 
      } 
  }
  </code></pre>