title: How do I append to array as an extension in swift
body: <p>I wrote the following in swift and expected it to just work:</p>
  <pre class="lang-swift prettyprint-override"><code>extension Array where Element : AnyCancellable
  {
      mutating func add( event : NSNotification.Name, handler: @escaping () -&gt; () )
      {
          let cancellation_token : AnyCancellable = event.sink( handler: handler)
          self.append(cancellation_token)        // error here
      }
  }
  </code></pre>
  <p>And I don't understand why it doesn't - it says &quot;<strong>no exact matches in call to append</strong>&quot;.
  And if I comment out the append line, it compiles.
  With this code however,</p>
  <pre class="lang-swift prettyprint-override"><code>extension Array where Element : AnyCancellable
  {
      mutating func add( event : NSNotification.Name, handler: @escaping () -&gt; () )
      {
          let cancellation_token : Element = event.sink( handler: handler)   // error here
          self.append(cancellation_token)
      }
  }
  </code></pre>
  <p>the assignment fails with a &quot;<strong>cannot convert value of type 'AnyCancellable' to specified type 'Element'</strong>&quot;.</p>
  <p>So it's like the where clause is doing nothing?<br />
  What am I doing wrong?</p>