How to pass closure with argument as argument and execute it?
<p>Initializer of class <code>A</code> takes an optional closure as argument:</p>

<pre><code>class A {
   var closure: ()?

   init(closure: closure()?) {
      self.closure = closure
      self.closure()
   }
}
</code></pre>

<p>I want to pass a function with an argument as the closure:</p>

<pre><code>class B {
    let a = A(closure: action(1)) // This throws the error: Cannot convert value of type '()' to expected argument type '(() -&gt; Void)?'

    func action(_ i: Int) {
       //...
    }
}
</code></pre>

<p>Class <code>A</code> should execute the closure <code>action</code> with argument <code>i</code>.</p>

<p>I am not sure about how to write this correctly, see error in code comment above. What has to be changed?</p>