<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="">Hi Diego,<div class=""><br class=""></div><div class="">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 class=""><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">struct</span> Vector {</div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> x: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Double</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> y: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Double</span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">init</span>() {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">x</span> = <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">y</span> = <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; }</div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">init</span>(x: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Double</span>, y: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Double</span>) {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">x</span> = y</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">y</span> = y</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div></div><div class=""><br class=""><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class="Apple-interchange-newline"><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""><font color="#8d8d8d" class="">Designer . Developer .  Nerd&nbsp;</font></span><font color="#464646" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">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; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><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; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On Jan 14, 2016, at 11:48 PM, Diego Barros via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_default"><font face="monospace, monospace" class="">Hi all,</font></div><div class="gmail_default"><font face="monospace, monospace" class=""><br class=""></font></div><div class="gmail_default"><font face="monospace, monospace" class="">​Given the ​following example:</font></div><div class="gmail_default"><font face="monospace, monospace" class=""><br class=""></font></div><div class="gmail_default"><div style="margin: 0px; font-size: 12px; line-height: normal;" class=""><font face="monospace, monospace" class="">struct Vector {</font></div><div style="margin: 0px; font-size: 12px; line-height: normal;" class=""><font face="monospace, monospace" class=""><span class="" style="white-space:pre">        </span>var x: Double</font></div><div style="margin: 0px; font-size: 12px; line-height: normal;" class=""><font face="monospace, monospace" class=""><span class="" style="white-space:pre">        </span>var y: Double</font></div><p style="margin:0px;font-size:12px;line-height:normal;min-height:17px" class=""><span class="" style="white-space:pre"><font face="monospace, monospace" class="">        </font></span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 12px; line-height: normal;" class=""><font face="monospace, monospace" class=""><span class="" style="white-space:pre">        </span>init() {</font></div><div style="margin: 0px; font-size: 12px; line-height: normal;" class=""><font face="monospace, monospace" class=""><span class="" style="white-space:pre">                </span><b class="">self.init(x: 0, y: 0)</b></font></div><div style="margin: 0px; font-size: 12px; line-height: normal;" class=""><font face="monospace, monospace" class=""><span class="" style="white-space:pre">        </span>}</font></div><p style="margin:0px;font-size:12px;line-height:normal;min-height:17px" class=""><span class="" style="white-space:pre"><font face="monospace, monospace" class="">        </font></span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 12px; line-height: normal;" class=""><font face="monospace, monospace" class=""><span class="" style="white-space:pre">        </span>init(x: Double, y: Double) {</font></div><div style="margin: 0px; font-size: 12px; line-height: normal;" class=""><font face="monospace, monospace" class=""><span class="" style="white-space:pre">                </span>self.x = y</font></div><div style="margin: 0px; font-size: 12px; line-height: normal;" class=""><font face="monospace, monospace" class=""><span class="" style="white-space:pre">                </span>self.y = y</font></div><div style="margin: 0px; font-size: 12px; line-height: normal;" class=""><font face="monospace, monospace" class=""><span class="" style="white-space:pre">        </span>}</font></div><div style="margin: 0px; font-size: 12px; line-height: normal;" class=""><font face="monospace, monospace" class="">}</font></div><div style="margin: 0px; font-size: 12px; line-height: normal;" class=""><font face="monospace, monospace" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal;" class=""><font face="monospace, monospace" class="">I'm just curious as to why the <i class="">self</i>&nbsp;(in bold) is needed in the init() that's calling init(x: Double, y: Double)? Can't the compiler infer from the parameters what should be called?</font></div><div style="margin: 0px; line-height: normal;" class=""><font face="monospace, monospace" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal;" class=""><font face="monospace, monospace" class="">- Diego</font></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="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="">
_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></blockquote></div><br class=""></div></div></body></html>