<div dir="ltr">Hi all,<div><br></div><div>In migrating to swift 4 I&#39;ve noticed one thing which has changed is there is no longer support for the automatic re-initialization of lazy variables.  </div><div><br></div><div>In swift 3 I could declare a variable like this:</div><div><br></div><div><font face="monospace, monospace">    lazy var myVar : MyType! = {</font></div><div><font face="monospace, monospace">        return makeMyVar()</font></div><div><font face="monospace, monospace">    }()</font></div><div><br></div><div>And then if I wanted that initialization block to be executed again, I could <font face="arial, helvetica, sans-serif">just nullify the variable:</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">    self.myVar = nil</font></div><div><br></div><div>It looks as if this was never intentional, and according to <a href="https://bugs.swift.org/browse/SR-5172">this bug report</a>, and now the nullified variable stay null rather than executing the initialization block a second time.</div><div><br></div><div>Has the possibility been discussed of providing a way to force lazy vars to initialize more than once?  Working with swift 3 I found this behavior to be very useful in some use cases.  For example in computer graphics it&#39;s a nice way to handle the generation of assets which only need to be created in the case of some relatively infrequent event, like for instance a window resize.  It seems I&#39;m not alone - the<a href="https://stackoverflow.com/questions/25072597/re-initialize-a-lazy-initialized-variable-in-swift"> top stack-overflow question</a> related to re-initializing lazy variables has over 10k views, so I suppose others have found a use case for this functionality as well.</div><div><div><div><br></div>Cheers,
</div></div><div>Spencer Kohan</div></div>