title: Does Swift closure retain captured variables?
body: <p>I discovered Swift closures are not retaining the captured variables unlike my expectation.</p>
  
  <pre><code>class AAA {
  }
  var a1  =   AAA() as AAA?                  // expects RC == 1
  var a2  =   { ()-&gt;AAA? in return a1 }      // expects RC == 2, retained by `Optional&lt;AAA&gt;`
  a1      =   nil                            // expects RC == 1
  a2()                                       // prints nil, ????
  </code></pre>
  
  <p>I am very confused with this because I have been believed the captured variables will be retained by default. But, if I capture it explicitly using capturing list, it is being retains.</p>
  
  <pre><code>class AAA {
  }
  var a1  =   AAA() as AAA?
  var a2  =   { [a1]()-&gt;AAA? in return a1 }
  a1      =   nil
  a2() // prints {AAA}, alive as expected.
  </code></pre>
  
  <p>I re-read the Swift manual, but I couldn't find related description. Capturing list is used to set <code>unowned</code> explicitly, and I am still confused.
  What is correct behavior and why does this happen?</p>