<div dir="ltr">+1 if this doesn't have terrible implications. <div><br></div><div>The downside to making it IUO or Optional is that that changes the type signature of `index(i:offsetBy:)` for no reason other than a default value. If you decide to change to or away from providing a default value it probably shouldn't change the type accepted in that spot. </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 22, 2017 at 7:32 PM, Ben Cohen via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></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"><br><div><div><div class="h5"><blockquote type="cite"><div>On Feb 22, 2017, at 10:42 AM, Nate Cook via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br class="m_1074355987617192004Apple-interchange-newline"><div><div style="word-wrap:break-word">Oops, left out that there's this horrifying way of writing it right now:<div><br></div><div><div><font face="Menlo">extension Collection {</font></div><div><font face="Menlo"> func index(_ i: Index! = nil, offsetBy n: IndexDistance) -> Index {</font></div><div><font face="Menlo"> let i = i ?? startIndex</font></div><div><font face="Menlo"> // ...</font></div><div><font face="Menlo"> }</font></div><div><font face="Menlo">}</font></div></div><div><br></div><div>Nobody wants that.</div><div><br></div></div></div></blockquote><div><br></div></div></div><div>Oh I don’t think it’s all that bad! It also doesn’t need to be an IUO, since you’re unwrapping it immediately into another variable no matter what.</div><div><br></div><div>This also gives you the flexibility to write this:</div><div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(52,149,175)"><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">extension</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> </span><span style="font-variant-ligatures:no-common-ligatures">Collection</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">func</span><span style="font-variant-ligatures:no-common-ligatures"> index(</span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">_</span><span style="font-variant-ligatures:no-common-ligatures"> i: Index? = </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">nil</span><span style="font-variant-ligatures:no-common-ligatures">, offsetBy n: IndexDistance) -> Index {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">let</span><span style="font-variant-ligatures:no-common-ligatures"> i = i ?? (n </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af"><</span><span style="font-variant-ligatures:no-common-ligatures"> 0 ? </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">endIndex</span><span style="font-variant-ligatures:no-common-ligatures"> : </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">startIndex</span><span style="font-variant-ligatures:no-common-ligatures">)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#008f00">// ...</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"> }</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">}</span></div><div><br></div></div><span class=""><blockquote type="cite"><div>______________________________<wbr>_________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br></div></blockquote></span></div><br></div><br>______________________________<wbr>_________________<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/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
<br></blockquote></div><br></div>