title: Confusion around closure in Swift strongly capturing variable used in it
body: <p>I have this code snippet:</p>
  
  <pre><code>class Animal {
      var stamina = 0
  
      func increaseStamina() {
          stamina += 1
      }
  
      deinit {
        print("gone")
      }
  }
  
  var animal : Animal? = Animal()
  let closure = {
    animal?.increaseStamina();
    print("closure end")
  }
  animal = nil //"gone"
  closure()
  </code></pre>
  
  <p>It prints "gone" immediately after setting animal to nil before calling the closure.
  But my understanding is that the closure also strongly captures the animal instance so the instance should be deallocated after the execution of closure, not before. What's wrong with my understanding here?</p>