Slashdot Mirror


7 Swift 2 Enhancements iOS Devs Will Love

snydeq writes: InfoWorld's Paul Solt outlines how Apple has made good on Swift's emphasis on performance, approachability, and ease in its latest update, offering up seven worthwhile enhancements to Swift 2, along with code samples. 'Many of the enhancements to Swift, through both the Swift 2.0 update and subsequent Swift 2.1 update, have made the language more explicit and intentional, and in turns, Swift 2 code will be safer and easier to maintain for years to come (especially now that Swift is open source). New language constructs (keywords) in Swift 2 improve the readability of control flow — the order in which lines of code are executed. Thanks to these new keywords, collaborating on Swift code will be much more productive and efficient.'

1 of 123 comments (clear)

  1. Guard is much more useful than you are thinking by SuperKendall · · Score: 3, Informative

    Guard has the nice side effect of turning an optional into a non-optional, so that you can use a value through a whole method without having to unwrap (or worse, force unwrap) it.

    without requiring the code-by-convention Disposable implementation

    Frankly that sounds a lot clunkier to me than just having a nice defer block.

    "repeat/while" is retarded and an unnecessary change away from well-known and accepted language conventions.

    I don't know how long you've been programming but over the years I have run across times where I wanted to run through a loop at least once before checking the end condition, and had to contort a variety of things to accommodate a check at the top of the loop... I hardly think such a useful tool is retarded, when is serves so well in a specific niche.

    Protocol extensions are nice, and are probably going to be quite useful in keeping your code readable. C# has had extension methods for a while now

    They aren't really the same as extension methods you are talking about, because protocol extensions allow for default implementations that get overridden... both Swift and ObjC have had extensions on classes forever.

    Swift protocol extensions are more like C# Abstract Classes. But you can have a class declare conformance to multiple protocols and so gain all of the methods from each, and furthermore you can in an extension on a class make any class implement a protocol and thus gain default protocol implementations...

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley