<div dir="ltr"><br>&gt; Swift, on the other hand, is different:<br>&gt; Init-methods are void-functions in every aspect, with the irregularity<div>&gt; that we can return &quot;nil&quot; (if the initializer is marked accordingly).<div><div class="gmail_extra"><br></div><div class="gmail_extra">Initializers are clearly not void-functions, as they return a value of type T.</div><div class="gmail_extra">And failable initializers return an Optional&lt;T&gt;.</div><div class="gmail_extra">Where T is the type to which the initializer belongs.</div><div class="gmail_extra"><br></div><div class="gmail_extra">If initializers where void-functions in every aspect, how would we explain what happens here:</div><div class="gmail_extra"><div class="gmail_extra">let a: Int = Int.init(123)</div><div class="gmail_extra">let b: Int? = Int.init(&quot;ff&quot;, radix: 16)</div><div class="gmail_extra">print(a) // 123</div><div class="gmail_extra">print(b) // 255</div><div>?</div><div><br></div><div>/Jens</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 9, 2016 at 11:32 AM, Tino Heth via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">As ease of use and performance implications have been discussed, I would still like to see the question of consistency addressed:<br>
In Objective-C, returning nil from an initializer is nothing special — it is a regular function that returns id (self in most cases).<br>
<br>
Swift, on the other hand, is different:<br>
Init-methods are void-functions in every aspect, with the irregularity that we can return &quot;nil&quot; (if the initializer is marked accordingly).<br>
<br>
Am I the only one who has the feeling that this is a little bit odd?<br>
What kind of method is a initializer in Swift?<br>
<br>
Tino<br>
<div class=""><div class="h5"><br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">bitCycle AB | Smedjegatan 12 | 742 32 Östhammar | Sweden<br><a href="http://www.bitcycle.com/" target="_blank">http://www.bitcycle.com/</a><br>Phone: +46-73-753 24 62<br>E-mail: <a href="mailto:jens@bitcycle.com" target="_blank">jens@bitcycle.com</a><br><br></div>
</div></div></div></div>