<div dir="ltr">Note that the compiler has a poor diagnostic for this case. I created <a href="https://bugs.swift.org/browse/SR-430">https://bugs.swift.org/browse/SR-430</a> a few weeks ago when I found this issue myself.</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 15, 2016 at 1:35 AM, Jo Albright via swift-users <span dir="ltr">&lt;<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi Diego,<div><br></div><div>Since you have not given the x &amp; y variables initial values, it requires them to be set inside the init. You can write it like below instead of calling the other self.init<br><div><br></div><div><span class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:#bb2ca2">struct</span> Vector {</div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px">    <br></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">    <span style="color:#bb2ca2">var</span> x: <span style="color:#703daa">Double</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">    <span style="color:#bb2ca2">var</span> y: <span style="color:#703daa">Double</span></div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px">    <br></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">    <span style="color:#bb2ca2">init</span>() {</div></span><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">        <span style="color:#4f8187">x</span> = <span style="color:#272ad8">0</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">        <span style="color:#4f8187">y</span> = <span style="color:#272ad8">0</span></div><span class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">    }</div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px">    <br></p><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">    <span style="color:#bb2ca2">init</span>(x: <span style="color:#703daa">Double</span>, y: <span style="color:#703daa">Double</span>) {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">        <span style="color:#bb2ca2">self</span>.<span style="color:#4f8187">x</span> = y</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">        <span style="color:#bb2ca2">self</span>.<span style="color:#4f8187">y</span> = y</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">    }</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</div></span></div><div><br><div>
<div style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><br><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important"><font color="#8d8d8d">Designer . Developer .  Nerd </font></span><font color="#464646"><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">Jo Albright</span></font><br style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"></div>
</div>
<br><div><blockquote type="cite"><div><div class="h5"><div>On Jan 14, 2016, at 11:48 PM, Diego Barros via swift-users &lt;<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>&gt; wrote:</div><br></div></div><div><div><div class="h5"><div dir="ltr"><div class="gmail_default"><font face="monospace, monospace">Hi all,</font></div><div class="gmail_default"><font face="monospace, monospace"><br></font></div><div class="gmail_default"><font face="monospace, monospace">​Given the ​following example:</font></div><div class="gmail_default"><font face="monospace, monospace"><br></font></div><div class="gmail_default"><div style="margin:0px;font-size:12px;line-height:normal"><font face="monospace, monospace">struct Vector {</font></div><div style="margin:0px;font-size:12px;line-height:normal"><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>var x: Double</font></div><div style="margin:0px;font-size:12px;line-height:normal"><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>var y: Double</font></div><p style="margin:0px;font-size:12px;line-height:normal;min-height:17px"><span style="white-space:pre-wrap"><font face="monospace, monospace">        </font></span><br></p><div style="margin:0px;font-size:12px;line-height:normal"><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>init() {</font></div><div style="margin:0px;font-size:12px;line-height:normal"><font face="monospace, monospace"><span style="white-space:pre-wrap">                </span><b>self.init(x: 0, y: 0)</b></font></div><div style="margin:0px;font-size:12px;line-height:normal"><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>}</font></div><p style="margin:0px;font-size:12px;line-height:normal;min-height:17px"><span style="white-space:pre-wrap"><font face="monospace, monospace">        </font></span><br></p><div style="margin:0px;font-size:12px;line-height:normal"><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>init(x: Double, y: Double) {</font></div><div style="margin:0px;font-size:12px;line-height:normal"><font face="monospace, monospace"><span style="white-space:pre-wrap">                </span>self.x = y</font></div><div style="margin:0px;font-size:12px;line-height:normal"><font face="monospace, monospace"><span style="white-space:pre-wrap">                </span>self.y = y</font></div><div style="margin:0px;font-size:12px;line-height:normal"><font face="monospace, monospace"><span style="white-space:pre-wrap">        </span>}</font></div><div style="margin:0px;font-size:12px;line-height:normal"><font face="monospace, monospace">}</font></div><div style="margin:0px;font-size:12px;line-height:normal"><font face="monospace, monospace"><br></font></div><div style="margin:0px;line-height:normal"><font face="monospace, monospace">I&#39;m just curious as to why the <i>self</i> (in bold) is needed in the init() that&#39;s calling init(x: Double, y: Double)? Can&#39;t the compiler infer from the parameters what should be called?</font></div><div style="margin:0px;line-height:normal"><font face="monospace, monospace"><br></font></div><div style="margin:0px;line-height:normal"><font face="monospace, monospace">- Diego</font></div></div></div>
</div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=ZKcnqA3HtCYQN0SS0ldgu-2BHgTHbQgLkA2VkY-2BvbJ2sx654I5mEPwyGFgrf5GxyudoGjC6GFkY4Xe5JmPPH-2FmtUdxVjorZrq33U5nu8sUCLEyQ2-2FAvd8QSDsckVFIbl-2FgFzYnw79X9UvvB2Ni3pC80y81QBAdlwyyaBOj7mjuSIjLeO5f-2FzrRy67JnWu8vabubpEb6gR4t0l5jTYvzmEC4w-3D-3D" alt="" width="1" height="1" border="0" style="min-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">
_______________________________________________<br>swift-users mailing list<br><a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-users" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br></div></blockquote></div><br></div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=PLxfwCJEjPeWvUDZqEq2h1e5BRs1s4m99sV2gcalz-2FQl-2F-2BQWF0zda0gwYNGYkltG7MoftO6ukzXTwzpv3yWhWi28K6ErLaf1JWGoyPtg92pjKdhwM6fk-2FBvxgD0hmuQ7h6FWa17Fgm3h5gOMZPfyr-2FqO5KkmYCDkgBlUSINIRSNkQHtIAyvkf3ZShy-2B0pR7zCSh4Goo0WKVpgzTXWIilQ3ScUxJjbI1Fm4KmegBR0u0-3D" alt="" width="1" height="1" border="0" style="min-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">
</div>
<br>_______________________________________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Trent Nadeau</div>
</div>