<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="">I believe that's a duplicate of "Proposal: Optional Binding Shorthand Syntax". Let me quote Chris Lattner on that:<div class=""><br class=""></div><div class=""><blockquote type="cite" class="">Right.<br class=""><br class="">“if let foo {“ is a frequently proposed extension to the syntax, but it is not one that we’re likely to ever add.<br class=""><br class="">I agree that this is a common pattern, and it would allow you to “write less code”, but that isn’t the goal of Swift. Since code is read more often than it is written, the real goal behind Swift is to let you write “more readable code” by eliminating boilerplate and other noise. <br class=""><br class="">Reducing syntax isn’t itself a goal, particularly if the result could/would be confusing for someone who has to read and maintain your code later.<br class=""><br class="">-Chris<br class=""></blockquote><div class="">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 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=""><font color="#929292" class=""><br class="Apple-interchange-newline">Pozdrawiam – Regards,</font></div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 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=""><font color="#929292" class="">Adrian Kashivskyy</font></div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">Wiadomość napisana przez Richard Fox <<a href="mailto:fox.ios.dev@gmail.com" class="">fox.ios.dev@gmail.com</a>> w dniu 04.12.2015, o godz. 00:13:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi all,<br class=""><br class="">I propose a shortened syntax for using if-let with local names unwrapping higher order optionals of the same name. i. e.<div class=""><pre style="overflow:auto;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.6px;margin-bottom:16px;font-stretch:normal;line-height:1.45;padding:16px;border-radius:3px;word-wrap:normal;color:rgb(51,51,51);margin-top:0px!important;background-color:rgb(247,247,247)" class=""><code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.6px;padding:0px;margin:0px;border-radius:3px;word-break:normal;border:0px;display:inline;max-width:initial;overflow:initial;line-height:inherit;word-wrap:normal;background:transparent" class="">if let a {
//code
}
</code></pre><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;line-height:25.6px" class="">as a shortcut for this:</p><pre style="overflow:auto;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.6px;margin-top:0px;font-stretch:normal;line-height:1.45;padding:16px;border-radius:3px;word-wrap:normal;color:rgb(51,51,51);margin-bottom:0px!important;background-color:rgb(247,247,247)" class=""><code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.6px;padding:0px;margin:0px;border-radius:3px;word-break:normal;border:0px;display:inline;max-width:initial;overflow:initial;line-height:inherit;word-wrap:normal;background:transparent" class="">if let a = a{
//code
}</code></pre><br class=""></div><div class="">From my observations echoing the local let variable name on the optional being unwrapped seems to have become the commonly used practice.<br class=""><br class="">I do not see this conflicting with any existing code.</div><div class=""><br class=""></div><div class="">My only thought's on potential pitfalls are if there is a local variable and higher order variable both with the same name, as there may be confusion as to which you are unwrapping. Although I don't see this as a huge issue, as fault for such an error seems like it would weigh mostly on architectural mistakes.<br class=""></div><div class=""><br class=""></div><div class="">Also I think this would go hand in hand with a guard implementation of the same nature<br class=""><pre style="overflow:auto;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.6px;margin-top:0px;font-stretch:normal;line-height:1.45;padding:16px;border-radius:3px;word-wrap:normal;color:rgb(51,51,51);margin-bottom:0px!important;background-color:rgb(247,247,247)" class=""><code style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.6px;padding:0px;margin:0px;border-radius:3px;word-break:normal;border:0px;display:inline;max-width:initial;overflow:initial;line-height:inherit;word-wrap:normal;background:transparent" class="">guard let a else{
//code
}</code></pre></div><div class=""><br class=""></div><div class="">Thanks,<br class="">Rich Fox</div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=Q0Y0L54uOhrrHtFzGFlMmzHCkni7p1uaN05dut7Y5S4o4Ud2IdheWrIrTitZg3CCFbeoQuPFsaZhX1DGFAvAgtBfL6OaGhhMawkHfGaO44jzrtpwaEjsTD1AlX-2BsYPg5L7QjvrRYTvoqtP876yxpKz6jGjFTfD0W8ZyCsZ-2FlSH1eDvEUR-2FvPRe5QJUPXH1v1B5vZcnyQUt4X5P0Vz6V-2Ba-2F8sYoCkrd8t4iy5dttaZb0-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-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>