[swift-users] In pursuit to a more idiomatic Swift

Erica Sadun erica at ericasadun.com
Mon Jan 4 13:31:40 CST 2016


Funny you should ask:

Migrating `if`s to `guard`s in Swift <http://ericasadun.com/2015/12/29/migrating-ifs-to-guards-in-swift/>
https://medium.com/swift-programming/why-swift-guard-should-be-avoided-484cfc2603c5 <https://medium.com/swift-programming/why-swift-guard-should-be-avoided-484cfc2603c5>
Another take on guard <http://ericasadun.com/2016/01/01/another-take-on-guard/>


> On Jan 4, 2016, at 11:18 AM, Adriano Ferreira via swift-users <swift-users at swift.org> wrote:
> 
> Hi everyone!
> 
> Jus wondering what is more idiomatic in Swift?
> 
> guard !array.isEmpty else {
>     return false
> }
> 
> or
> 
> if array.isEmpty {
>     return false
> }
> 
> 
> What about when it comes to indentation style?
> 
> if array.isEmpty {
>     return false
> }
> 
> Or is there an exception of simple one-liners? Is it still 1TBS <https://en.wikipedia.org/wiki/Indent_style#Variant:_1TBS>?
> 
> if array.isEmpty { return false }
> 
> Both styles are present in Apple’s Swifts projects on GitHub.
> 
> 
> Best,
> 
> — A
> 
>> On Dec 21, 2015, at 11:01 PM, Adriano Ferreira via swift-users <swift-users at swift.org <mailto:swift-users at swift.org>> wrote:
>> 
>> Hi everyone!
>> 
>> 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.
>> 
>> I’d appreciate any ideas on how to improve those algorithms into a more Swift-y form.
>> 
>> So, here is the repository <https://github.com/adrfer/Sort>.
>> 
>> Best,
>> 
>> — A
>> 
>> 
>> 
>> _______________________________________________
>> swift-users mailing list
>> swift-users at swift.org <mailto:swift-users at swift.org>
>> https://lists.swift.org/mailman/listinfo/swift-users <https://lists.swift.org/mailman/listinfo/swift-users>
> 
>  _______________________________________________
> swift-users mailing list
> swift-users at swift.org <mailto:swift-users at swift.org>
> https://lists.swift.org/mailman/listinfo/swift-users <https://lists.swift.org/mailman/listinfo/swift-users>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160104/b94bc17b/attachment.html>


More information about the swift-users mailing list