<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="">Hi everyone!<div class=""><br class=""></div><div class="">Jus wondering what is more idiomatic in Swift?</div><div class=""><br class=""></div><div class="">guard !array.isEmpty else {</div><div class=""> return false</div><div class="">}</div><div class=""><br class=""></div><div class="">or</div><div class=""><br class=""></div><div class="">if array.isEmpty {</div><div class=""> return false</div><div class="">}</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">What about when it comes to indentation style?</div><div class=""><br class=""></div><div class=""><div class=""><div class="">if array.isEmpty {</div><div class=""> return false</div><div class="">}</div></div></div><div class=""><br class=""></div><div class="">Or is there an exception of simple one-liners? Is it still <a href="https://en.wikipedia.org/wiki/Indent_style#Variant:_1TBS" class="">1TBS</a>?</div><div class=""><br class=""></div><div class=""><div class="">if array.isEmpty { return false }</div></div><div class=""><br class=""></div><div class="">Both styles are present in Apple’s Swifts projects on GitHub.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Best,</div><div class=""><br class=""></div><div class="">— A</div><div class=""><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 21, 2015, at 11:01 PM, Adriano Ferreira via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi everyone!<div class=""><br class=""></div><div class="">While learning and in pursuit a to more idiomatic Swift, I put together a playground where I’ve been experimenting with some simple sorting techniques.</div><div class=""><br class=""></div><div class="">I’d appreciate any ideas on how to improve those algorithms into a more Swift-y form.</div><div class=""><br class=""></div><div class="">So, <a href="https://github.com/adrfer/Sort" class="">here is the repository</a>.</div><div class=""><br class=""></div><div class="">Best,</div><div class=""><br class=""></div><div class="">— A</div><div class=""><br class=""></div><div class=""><br class=""></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=Q0Y0L54uOhrrHtFzGFlMm3oC4gejexfeaix2NKEDTe7YeuWqFcUUfAnU9UaJwEynz4Ke0FaJ0lpZNrVWJoageykaguIrXkOhuTOFkXUNrCmA4hjdMRMvEDSW495k2JNsr-2BjABTjjmdlaNVDfQZkXeU07rqNdwsArIII7IdnMVUQx1S2Ne51LqVCncD-2BO6kHQLMjn03TXKWXO6l6dVi0gNTBwYv60xI1EX6zG9EY3NwY-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="">
</div>
_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></blockquote></div><br class=""></div></div></body></html>