Apple has released Swift 5.2 with the release of Xcode 11.4. We have added support for Swift 5.2, you can now choose between Swift 5.1 and Swift 5.2 in the online version of Swiftify.
What's New in Swift 5.2?
Swift 5.2 allows us to use keypaths expression as functions.
This can be better understood through a simple code sample:
Now let's create some instances of that struct and put them into an array, like this:
Now let us do the following operations on this array of users:
- Get an Array of user names
- Get a filtered list of users who can vote
- Get a list of best friends of a user
Here is how it was done in Swift 5.1
Here is how this can be done using keypaths in Swift 5.2
This change has been incorporated into our Online converter here.
For those still using Swift 5.1, you can still choose between Swift 5.1 and 5.2.
Apart from this some of the other notable new features in Swift 5.2 are:
- Subscripts can now declare default arguments
- New and improved diagnostics which is especially helpful when working with SwiftIUI