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

Adriano Ferreira adriano.ferreira at me.com
Mon Jan 4 12:18:29 CST 2016


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> 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
> 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/559191da/attachment.html>


More information about the swift-users mailing list