<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></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 Mar 11, 2017, at 9:49 AM, <a href="mailto:andrew@arnopoulos.io" class="">andrew@arnopoulos.io</a> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class=""></div><div class="">How would that work for a subclass, if all properties of a class need to be initialized before the parent's initializer is called?</div><div class=""><br class=""></div><div class="">-Andrew</div><div class=""><br class="">On Mar 11, 2017, at 8:46 AM, Derrick Ho via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class="">Seems like it should work.  Maybe it is a bug that should be reported to SR.<br class=""><br class="">Does this error occur for non-failable initializers?<br class=""><div class="gmail_quote"><div dir="ltr" class="">On Sat, Mar 11, 2017 at 12:33 AM David Sweeris via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg">Is this a feature or a bug?<blockquote style="margin:0 0 0 40px;border:none;padding:0px" class="gmail_msg"><div class="gmail_msg"><div style="margin:0px;line-height:normal" class="gmail_msg"><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="gmail_msg">class</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> Foo {</span></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="gmail_msg">let</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> bar: </span><span style="font-variant-ligatures:no-common-ligatures;color:#703daa" class="gmail_msg">Int</span></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="gmail_msg">init</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">?(someConditionBasedOnInputData: </span><span style="font-variant-ligatures:no-common-ligatures;color:#703daa" class="gmail_msg">Bool</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">) {</span></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="gmail_msg">var</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> localBar: </span><span style="font-variant-ligatures:no-common-ligatures;color:#703daa" class="gmail_msg">Int</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> = </span><span style="font-variant-ligatures:no-common-ligatures;color:#272ad8" class="gmail_msg">0</span></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="gmail_msg">defer</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> {</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class="gmail_msg"><span style="font-variant-ligatures: no-common-ligatures;" class="gmail_msg">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bar =&nbsp;localBar&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">//Cannot assign to property: 'bar' is a 'let' constant</span></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp; &nbsp; &nbsp; &nbsp; }</span></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="gmail_msg">if</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp;someConditionBasedOnInputData&nbsp;{</span></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="gmail_msg">return</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="gmail_msg">nil</span></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp; &nbsp; &nbsp; &nbsp; }</span></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp; &nbsp; }</span></div><div style="margin:0px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">}</span></div></div></div></blockquote>It’d be handy to be able to do the assignment upfront in a defer block in cases where there’s both a bunch of validation to do on the input data, and no harm from assigning the interim values to the final values when you’re about to return nil anyway.</div></blockquote></div></div></blockquote></div></div></blockquote><br class=""></div><div>If I was trying to subclass something and add extra instance variables, yeah, I don’t think it would work. I’m not trying to subclass anything in this case, though.</div><br class=""><div class="">- Dave Sweeris</div></body></html>