title: Swift optional escaping closure parameter
body: <p>Given:</p>
  
  <pre><code>typealias Action = () -&gt; ()
  
  var action: Action = { }
  
  func doStuff(stuff: String, completion: @escaping Action) {
      print(stuff)
      action = completion
      completion()
  }
  
  func doStuffAgain() {
      print("again")
      action()
  }
  
  doStuff(stuff: "do stuff") { 
      print("swift 3!")
  }
  
  doStuffAgain()
  </code></pre>
  
  <p>Is there any way to make the <code>completion</code> parameter (and <code>action</code>) of type <code>Action?</code> and also keep <code>@escaping</code> ?</p>
  
  <p>Changing the type gives the following error:</p>
  
  <blockquote>
    <p>@escaping attribute only applies to function types</p>
  </blockquote>
  
  <p>Removing the <code>@escaping</code> attribute, the code compiles and runs, but doesn't seem to be correct since the <code>completion</code> closure is escaping the scope of the function.</p>