title: How Swift captures mutable and immutable struct
body: <p>I'm confused about how Swift captures mutable and immutable struct</p>
  
  <p>My code downloads images asynchronously, and after the download finish, the completion closure will be called.</p>
  
  <p>In the following code, It prints captured <code>index</code> value. The first code will print only <code>17</code>. But the second code will print <code>0 1 2 ... 16</code>. ( sponsorClass.count == 17 )</p>
  
  <hr>
  
  <p>The firs code is</p>
  
  <pre><code>var index = 0
  for sponsor in sponsorClass{
      var image = AsynchronousLoadImage( sponsor.imageURL ){ loadedImage in
          println("\(index)") //print 17
      }
      index++
  }
  </code></pre>
  
  <hr>
  
  <p>and the second code is</p>
  
  <pre><code>var index = 0
  for sponsor in sponsorClass{
      let tempIndex = index
      var image = AsynchronousLoadImage( sponsor.imageURL ){ loadedImage in
          println("\(tempIndex)") //print 0,1,2,..,16
      }
      index++
  }
  </code></pre>