title: Using let on mutating variable
body: <p>I have a simple custom class that for the sake of simplicity in the example lets say it contains a single property that is an array of arrays of strings.  It has a single method that moves the first object from one array to another.  Ignore the missing initializer, this is a truncated version of an existing class I've written.</p>
  
  <pre><code>class MyClass: NSObject
  {
      var strings:Array&lt; Array&lt; String &gt; &gt;
  
      func makeMove(fromArray:Int, toArray:Int)
      {
          var from = strings[fromArray] as Array&lt; String &gt;
          var to = strings[toArray]
  
          let top = from[0]
          to.append(top)
          from.removeAtIndex(0)
  
          towers[fromTower] = from
          towers[toTower] = to
      }
  }
  </code></pre>
  
  <p>If I declare a new instance of <code>MyClass</code> and call this single method on it, I get a compiler warning stating that the instance was never modified and should be made a <code>let</code> instead of <code>var</code>. </p>
  
  <pre><code>var myInstance = MyClass()    //Warning
  myInstance.makeMove(0, toArray:1)
  
  
  let myInstance = MyClass()    //No warning
  myInstance.makeMove(0, toArray:1)
  </code></pre>
  
  <p>Interestingly enough, even though in the second instance it is a <code>let</code>, which should be a constant, the instance does in fact get mutated when <code>makeMove</code> is called on it.  </p>
  
  <p>Whats wrong in this case?  Should I use a <code>let</code>, or is the compiler not properly recognizing that it is a mutating function?</p>