What's New in Swift 4.2

Swift_42-2.jpg

The second update release to Swift of 2018, Swift 4.2 introduces some great improvements to the language. Read this post to learn how they can help you write even better code.

Included in this version’s list of improvements:

  • SE-0194: Adds the CaseIterable protocol to automatically generate an array of all the possible enum cases.

  • SE-0195: Dynamic member lookup syntactical sugar.

  • SE-0196: New compiler directives #warning and #error.

  • SE-0197: New removeAll(where:) method to perform optimized in-place filter for collections.

  • SE-0199: New toggle() method to easily toggle/flip boolean values.

  • SE-0202: New native random number generator.

  • SE-0206: New Hasher type to improve and simplify conformance to the Hashable protocol.

  • SE-0207: New allSatisfy() method to verify all elements in a sequence pass a condition. 

  • SE-0194: Conditional conformance improvements.

Read my take on each of those changes, exclusively at Tuts+.

Doron KatzSwift, News