<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="">Since Swift 3.0, they are no longer a normal type like Optional&lt;T&gt;. See&nbsp;<a href="https://github.com/apple/swift-evolution/blob/master/proposals/0054-abolish-iuo.md" class="">SR-0054</a><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 11, 2016, at 11:54 AM, Muhammad Tahir Vali via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Im curious to know the reasoning behind why implicit-wrapped optionals aren't allowed when creating tuples. Below is an example with type aliases and anonymous tuples.<div class=""><div class=""><br class=""></div><div class="">ex.&nbsp;</div><div class=""><div style="margin: 0px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(195,34,117)" class="">typealias</span><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp;Name = (first: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-variant-ligatures:no-common-ligatures" class="">!, middle: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-variant-ligatures:no-common-ligatures" class="">?, last: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-variant-ligatures:no-common-ligatures" class="">!)</span></div></div><div class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><div class=""><div style="margin: 0px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(195,34,117)" class="">typealias</span><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp;Name = (first:&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-variant-ligatures:no-common-ligatures" class="">!, middle:&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-variant-ligatures:no-common-ligatures" class="">?, last:&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-variant-ligatures:no-common-ligatures" class="">!)!</span></div><div style="margin: 0px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><span style="color:rgb(195,34,117)" class="">var</span>&nbsp;name : (</span><span style="font-variant-ligatures:no-common-ligatures" class="">first:&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-variant-ligatures:no-common-ligatures" class="">!, middle:&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-variant-ligatures:no-common-ligatures" class="">?, last:&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-variant-ligatures:no-common-ligatures" class="">!</span>)</div></div><div class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><span style="font-family:menlo;font-variant-ligatures:no-common-ligatures" class=""><font color="#c32275" class="">var&nbsp;</font>name : (first:&nbsp;</span><span style="font-family:menlo;font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-family:menlo;font-variant-ligatures:no-common-ligatures" class="">!, middle:&nbsp;</span><span style="font-family:menlo;font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-family:menlo;font-variant-ligatures:no-common-ligatures" class="">?, last:&nbsp;</span><span style="font-family:menlo;font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-family:menlo;font-variant-ligatures:no-common-ligatures" class="">!)!</span><br class=""></span></div><div class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><span style="font-family:menlo;font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></span></div><div class=""><span style="font-variant-ligatures:no-common-ligatures" class="">error from all 4 examples above:</span></div><div class=""><span style="font-variant-ligatures:no-common-ligatures" class="">Implicitly unwrapped optionals are only allowed at top level and as function results</span></div><div class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures:no-common-ligatures" class="">I also noticed that I can modify tuples using functions ONLY if I use <b class="">inout</b>.&nbsp;</span></div><div class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><div style="margin: 0px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(195,34,117)" class="">func</span><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp;name(Person :&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(195,34,117)" class="">inout</span><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp;(first:&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-variant-ligatures:no-common-ligatures" class="">?, middle:&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-variant-ligatures:no-common-ligatures" class="">?, last:&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="">String</span><span style="font-variant-ligatures:no-common-ligatures" class="">?)) {</span></div><div style="margin: 0px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; &nbsp;&nbsp;Person.first =&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(201,27,19)" class="">"John"</span></div><div style="margin: 0px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; &nbsp;&nbsp;Person.last =&nbsp;</span><span style="color:rgb(201,27,19)" class="">"Doe"</span></div><div style="margin: 0px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">}</span></div><div style="margin: 0px; line-height: normal; font-family: menlo;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; font-family: menlo;" class="">OR&nbsp;</div><div style="margin: 0px; line-height: normal; font-family: menlo;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures;color:rgb(195,34,117)" class="">func</span><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp;name(Person :&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(195,34,117)" class="">inout</span><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp;Name</span><span style="font-variant-ligatures:no-common-ligatures" class="">) {</span></div><div style="margin: 0px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; &nbsp;&nbsp;Person.first =&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(201,27,19)" class="">"John"</span></div><div style="margin: 0px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">&nbsp; &nbsp;&nbsp;Person.last =&nbsp;</span><span style="color:rgb(201,27,19)" class="">"Doe"</span></div><p style="margin:0px;line-height:normal;font-family:menlo" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""></span></p><div style="margin: 0px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">}</span></div><div class=""><br class=""></div><div class="">This is because tuples are passed into functions as 'let' constants. Why not add the ability to modify a copy of the tuple inside the function ?</div><div class=""><br class=""></div></span></span></div></span></div><div class=""><br class=""></div>-- <br class=""><div class="gmail_signature"><div dir="ltr" class="">Best Regards,<div class=""><br class=""></div><div class="">Muhammad T. Vali</div></div></div>
</div></div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></body></html>