title: Swift: reusing a closure definition (with typealias)
body: <p>I'm trying to do create some closure definitions which I'm gonna use a lot in my iOS app. So I thought to use a typealias as it seemed the most promising ...</p>
  
  <p>I did a small Playground example which shows my issue in detail</p>
  
  <pre><code>// Here are two tries for the Closure I need
  typealias AnonymousCheck = (Int) -&gt; Bool
  typealias NamedCheck = (number: Int) -&gt; Bool
  
  // This works fine
  var var1: AnonymousCheck = {
      return $0 &gt; 0
  }
  var1(-2)
  var1(3343)
  
  // This works fine
  var var2: NamedCheck = {
      return $0 &gt; 0
  }
  var2(number: -2)
  var2(number: 12)
  
  // But I want to use the typealias mainly as function parameter!
  // So:
  
  // Use typealias as function parameter
  func NamedFunction(closure: NamedCheck) {
      closure(number: 3)
  }
  func AnonymousFunction(closure: AnonymousCheck) {
      closure(3)
  }
  
  // This works as well
  // But why write again the typealias declaration?
  AnonymousFunction({(another: Int) -&gt; Bool in return another &lt; 0})
  NamedFunction({(another: Int) -&gt; Bool in return another &lt; 0})
  
  // This is what I want... which doesn't work
  // ERROR: Use of unresolved identifier 'number'
  NamedFunction({NamedCheck in return number &lt; 0})
  
  // Not even these work
  // ERROR for both: Anonymous closure arguments cannot be used inside a closure that has exlicit arguments
  NamedFunction({NamedCheck in return $0 &lt; 0})
  AnonymousFunction({AnonymousCheck in return $0 &lt; 0})
  </code></pre>
  
  <p>Am I missing something or is it just not supported in Swift?
  Thanks</p>
  
  <p>EDIT/ADDITION:</p>
  
  <p>The above is just a simple example. In real life my typealias is more complicated. Something like:</p>
  
  <pre><code>typealias RealLifeClosure = (number: Int, factor: NSDecimalNumber!, key: String, upperCase: Bool) -&gt; NSAttributedString
  </code></pre>
  
  <p>I basically want to use a typealias as a shortcut so I don't have to type that much. Maybe typealias isn't the right choice... Is there another?</p>