<div dir="ltr">I attempted the following code which involves passing a closure – one that doesn't escape obviously – but the compiler complains that I need to make formHeaders and formStream vars.<div><br><div><div> public func finish() throws -> ([String:String],InputStream) {</div><div> let formHeaders: [String:String]</div><div> let formStream: InputStream</div><div> try finish({ (fh, fs, _) in</div><div> formHeaders = fh</div><div> formStream = fs</div><div> })</div><div> return (formHeaders, formStream)</div><div> }</div></div></div><div><br></div><div>If I have code like this however the use of let is ok.</div><div><br></div><div><div> public func finish() throws -> ([String:String],InputStream) {</div><div> let formHeaders: [String:String]</div><div> let formStream: InputStream</div><div> if self.finalized.get() {</div><div> formHeaders = ["foo":"bar"]</div><div> //formStream = ...</div><div> }</div><div> else {</div><div> formHeaders = [:]</div><div> //formStream = ...</div><div> // or throw something here</div><div> }</div><div> return (formHeaders, formStream)</div><div> }</div></div><div><br></div><div>If the closure is non-escaping and the code as structured the compiler should be able to reason about the initialization correctness of those lets...? ...or am I missing something?</div><div><br></div><div>-Shawn</div></div>