title: Swift- variable not initialized before use (but it's not used)
body: <p>Currently I've got some swift code like this:</p>
  
  <pre><code>class C {
     let type: Type;
     var num = 0;
     init() {
         self.type = Type({ (num: Int) -&gt; Void in
             self.num = num;
         });
     }
  }
  </code></pre>
  
  <p>The Swift compiler refuses to permit it, saying that I've referenced <code>self.type</code> before it's initialized, even though that's clearly completely untrue. Furthermore, I can't employ the workaround found in other questions/answers, because the <code>type</code> is not optional, and it's immutable, so it can't be initialized with <code>nil</code> pointlessly first.</p>
  
  <p>How can I make the Swift compiler accept this perfectly valid code?</p>
  
  <p>This has nothing to do with returning from the initializer early. The callback is executed asynchronously- it is stored and then used later.</p>
  
  <p>I also have a few further <code>let</code>s that are initialized after this one. I would have to turn them <em>all</em> into mutable optionals, even though they're not optional and can't be mutated.</p>