<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 21, 2015, at 5:14 PM, Erica Sadun via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">For a friend:</div><div class=""><br class=""></div><div class="">This won't work.</div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">class DerpController {</font></div><div class=""><font face="Menlo" class=""> private(set) var derp: Bool = {</font></div><div class=""><font face="Menlo" class=""> return _findDerp() != nil</font></div><div class=""><font face="Menlo" class=""> }()</font></div><div class=""><font face="Menlo" class=""> </font></div><div class=""><font face="Menlo" class=""> private func _findDerp() -> AnyObject? {</font></div><div class=""><font face="Menlo" class=""> return nil</font></div><div class=""><font face="Menlo" class=""> }</font></div><div class=""><font face="Menlo" class="">}</font></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">but this works:</div><div class=""><br class=""></div><div class=""><div class=""><font face="Menlo" class="">private func _findDerp() -> AnyObject? {</font></div><div class=""><font face="Menlo" class=""> return nil</font></div><div class=""><font face="Menlo" class="">}</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">class DerpController {</font></div><div class=""><font face="Menlo" class=""> private(set) var derp: Bool = {</font></div><div class=""><font face="Menlo" class=""> return _findDerp() != nil</font></div><div class=""><font face="Menlo" class=""> }()</font></div><div class=""><font face="Menlo" class=""> </font></div><div class=""><font face="Menlo" class="">}</font></div></div><div class=""><br class=""></div><div class="">Is it because the var member cannot depend on another member during setup? Thanks in advance for insight.</div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=RoDF4MveSEMYBIqIJA6ub1g8cOZ-2BVYvqV-2FqygPhjPn-2FkmP2hQffDvH2Jzuh77saLN5A-2BRX85iCG30Opiir2k-2FhmWZo4Wk-2BHQ2EnTEYHMuJcXbYVbFvmYgfUCtXv4wrWC5Wtkd6q-2BUTyhjqInpbCLq-2Bwx2A-2Fu9v9HbtpLw8ZgGEL-2BfyPP4V2Q6-2Fb6ZvJBNG8jtltlF4WQsszzbtvBMci5U8EEhTmEGCnhI-2FTYu1-2Fr2RI-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
</div></div></blockquote><br class=""></div><div>Yeah, instance methods can't be called until `self` is fully initialized, since they may themselves touch the uninitialized instance. In addition to making the function global, you could also make it a static method to preserve namespacing.</div><br class=""></body></html>