Updating to Swift 4.2

Swift 4.2 is a major release and shipped with Xcode 10. It comes with a lot of code improvements for which the best way to start is to watch the WWDC 2018: What’s New in Swift session. Some of the improvements are easy to implement in your existing code. Replace strongSelf with self SE-0079 makes … 

 

Defer usage in Swift

Although the defer keyword was already introduced in Swift 2.0, it’s still quite uncommon to use it in projects. Its usage can be hard to understand, but using it can improve your code a lot in some places. The most common use case seen around is opening and closing a context within a scope How … 

 

Where usage in Swift

Where is a powerful keyword within Swift to easily filter out values. It can be used in many different variants from which most of them are listed in this post. Usage in a switch Consider having the following enum: enum Action { case createUser(age: Int) case createPost case logout } Using where you can easily …