title: Why popFirst throws an error, but removeFirst works?
body: <pre><code>struct Queue&lt;T&gt;{
  
      private var elements : [T] = []
  
      public mutating func enqueue(_ element: T){
          elements.append(element)
      }
      public mutating func dequeue() -&gt; T?{
          return elements.popFirst()  // ERROR!
      }
      public mutating func dequeue2() -&gt; T?{
          return elements.removeFirst()
      }
  }
  </code></pre>
  
  <p>The error I get for <code>popFirst</code> is:</p>
  
  <blockquote>
    <p>cannot use mutating member on immutable value: 'self' is
    immutable</p>
  </blockquote>
  
  <p>Both <a href="https://developer.apple.com/documentation/swift/arrayslice/1687956-popfirst" rel="noreferrer"><code>popFirst</code></a> and <a href="https://developer.apple.com/documentation/swift/array/2884646-removefirst" rel="noreferrer"><code>removeFirst</code></a> are marked as <code>mutating</code> and both return and <code>T?</code>. So why isn't it working?</p>
  
  <p><strong>EDIT:</strong>  As others have commented, it seems to be some sort of bug. It's been discussed in the forums <a href="https://forums.swift.org/t/swift-4-cannot-use-mutating-member-on-immutable-value-self-is-immutable/6642" rel="noreferrer">here</a>.</p>
  
  <p><strong>EDIT:</strong> Still happens in Xcode 9.4.1 (Swift 4.1.2)</p>