Swift 4.2 - What's New
In this post, I would like to share what’s new in Swift 4.2. All the code displayed in this post is available at my GitHub repo my-learnings/Swift4.2.
Random Number Generation
- Swift 4.2 added random number generator API to standard library. You can use it on
Int,Double,Float,CGFloatandBool. - It also provides a convenient API
randomElementwhich returns a random element from a sequence - It also provides the APIs
shuffleandshuffledto shuffle a sequence
|
|
Dynamic Member Lookup
Swift 4.2 introduces a dot syntax to access custom subscripts; this is much cleaner than the earlier square bracket calls. The compiler evaluates the subscript call dynamically at runtime, but provides a cleaner syntax.