title: Swift Array: Cannot invoke 'append' with an argument list of type '(Int)'
body: <p>I'm trying to implement a padding function for Array:</p>
  
  <pre><code>extension Array {
      func dataWithPadding(offset: Int, length: Int, paddingLength: Int) -&gt; NSData {
          var arr = Array(self[offset..&lt;(offset + length)])
          arr = arr.reverse()
          for (var i = 0; i &lt; paddingLength; i++) {
              arr.append(0)
          }
          let d = NSData(bytesNoCopy: &amp;arr, length: length)
          return d
      }
  }
  </code></pre>
  
  <p>This errors at <code>arr.append</code> with:</p>
  
  <blockquote>
    <p>Cannot invoke 'append' with an argument list of type '(Int)'</p>
  </blockquote>
  
  <p>I try to change the declaration into:</p>
  
  <pre><code>var arr[UInt8] = Array(self[offset..&lt;(offset + length)])
  </code></pre>
  
  <p>However, this also errors:</p>
  
  <blockquote>
    <p>Cannot assign to immutable expression of type '[UInt8].Type' (aka 'Array.Type')</p>
  </blockquote>
  
  <p>The weird part: I try to run the original code with <code>arr.append</code> commented out, and use <code>lldb</code> to directly run <code>arr.append(0)</code>, it actually works.</p>
  
  <p>I'm using Xcode 7.2.</p>