<div dir="ltr">Why would you do this just for return statements?  Why not do postfix conditionals for all statements (like ruby)?<div><br></div><div>I&#39;ve always liked postfix conditionals, but not enough to suggest them.  Mostly I&#39;m curious about limiting the scope to return statements.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 4, 2016 at 7:31 AM, Christian Kienle 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">+1</div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">2016-08-04 15:38 GMT+02:00 Julian Dunskus via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span>:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div style="word-wrap:break-word">How often have you written something like the following?<div><br></div><div>`</div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:#b51b47">if</span><span> indexPath.row == </span><span style="color:#7373ff">0</span><span> { </span><span style="color:#b51b47">return</span><span> }</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span></span><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:#b51b47">guard</span><span> </span><span style="color:#b51b47">let</span><span> thing = things[index] </span><span style="color:#b51b47">else</span><span> { </span><span style="color:#b51b47">return nil</span><span> }</span></div></div><div>`</div><div><br></div><div>I propose adding some syntactic sugar to make such statements more readable and simple to write:</div><div><br></div><div>`</div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:#b51b47">return</span><span> </span><span style="color:#b51b47">if</span><span> indexPath.row == </span><span style="color:#7373ff">0</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span></span><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:#b51b47">return</span><span> </span><span style="color:#b51b47">nil</span><span> <span style="color:rgb(181,27,71)">unless</span> </span><span style="color:#b51b47">let</span><span> thing = things[</span><span style="color:#cc4428">index</span><span>]</span></div></div><div>`</div><div><br></div><div>I don’t know how easy or hard this would be to implement, but I think it would improve some code significantly.</div><span><font color="#888888"><div><br></div><div>–Julian Dunskus</div></font></span></div><br></div></div>_______________________________________________<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" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div data-smartmail="gmail_signature"><div dir="ltr"><font face="arial, helvetica, sans-serif" style="font-size:12.8000001907349px">Mit freundlichen Grüßen</font><div style="font-size:12.8000001907349px"><font face="arial, helvetica, sans-serif"><br></font></div><div style="font-size:12.8000001907349px"><font face="arial, helvetica, sans-serif"><b>Christian Kienle</b></font></div><div style="font-size:12.8000001907349px"><font face="arial, helvetica, sans-serif">Mobile Developer</font></div><div style="font-size:12.8000001907349px"><font face="arial, helvetica, sans-serif"><br></font></div><div style="font-size:12.8000001907349px"><font face="arial, helvetica, sans-serif"><b>REWE Digital GmbH</b></font></div><div style="font-size:12.8000001907349px"><font face="arial, helvetica, sans-serif">Domstraße 20, 50668 Köln, Büro: Schanzenstr. 6-20, 51063 Köln</font></div><div style="font-size:12.8000001907349px"><font face="arial, helvetica, sans-serif">Geschäftsführer: Dr. Jean-Jacques Michel van Oosten (Vorsitzender), Christoph Eltze, Dr. Johannes Steegmann, Dr. Robert Zores</font></div><div style="font-size:12.8000001907349px"><font face="arial, helvetica, sans-serif">Handelsregister: Amtsgericht Köln (HRB 78670) UST-ID-Nr.: DE 290 605 450</font></div><div style="font-size:12.8000001907349px"><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif" style="font-size:12.8000001907349px">Telefon: +49 </font><font face="arial, helvetica, sans-serif">151 11441782</font></div><div style="font-size:12.8000001907349px"><span style="font-family:arial,helvetica,sans-serif;font-size:12.8000001907349px">E-Mail: </span><a href="mailto:christian.kienle@rewe-digital.com" style="font-family:arial,helvetica,sans-serif;font-size:12.8000001907349px;color:rgb(17,85,204)" target="_blank">christian.kienle@rewe-digital.com</a><br></div><div style="font-size:12.8000001907349px"><font face="arial, helvetica, sans-serif">Internet: <u><a href="http://www.rewe-digital.com/" style="color:rgb(17,85,204)" target="_blank">www.rewe-digital.com</a></u></font></div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px"><font face="arial, helvetica, sans-serif">Ein Unternehmen der <b>REWE GROUP</b></font></div><div style="font-size:12.8000001907349px"><font face="arial, helvetica, sans-serif"><a href="http://www.rewe-group.com/" style="color:rgb(17,85,204)" target="_blank">http://www.rewe-group.com</a></font></div></div></div>
</div>
<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>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">kurt@CircleW.org<br><a href="http://www.CircleW.org/kurt/" target="_blank">http://www.CircleW.org/kurt/</a><br></div>
</div>