title: What's the difference between using the "self." prefix and writing "self" in the capture list of a closure?
body: <p>I was writing some code similar to:</p>
  <pre><code>class ViewController : UIViewController {
      var foo = &quot;foo&quot;
      override func viewDidLoad() {
          let alert = UIAlertController(title: &quot;&quot;, message: &quot;&quot;, preferredStyle: .alert)
          alert.addAction(UIAlertAction(title: &quot;&quot;, style: .default, handler: { _ in
              print(foo)
          }))
      }
  }
  </code></pre>
  <p>Xcode reports an error at <code>print(foo)</code> that I forgot to capture <code>self</code>, and suggests <em>two</em> fixes.:</p>
  <ol>
  <li><p><code>print(self.foo)</code>, or;</p>
  </li>
  <li><p>Add a capture list of <code>[self]</code> to the closure: <code>... handler: { [self] _ in ...</code></p>
  </li>
  </ol>
  <p>Now, I remember that before Xcode 12/Swift 5.3, it didn't use to do that. It either gives no fixes, or just the first one.</p>
  <p>My question is, what's the difference between these two fixes? Do they somehow capture <code>self</code> in a different way?</p>
  <p>The <a href="https://docs.swift.org/swift-book/LanguageGuide/Closures.html#ID546" rel="nofollow noreferrer">Language Guide</a> seems to touch on this a little bit, but doesn't seem to say what the difference between them is.</p>