Skip to main content

Mike Kreuzer

Conditional conformance in Swift 4.2

7 June 2018

Exciting new stuff coming out of WWDC this week, including info on what's new in Swift 4.2.

Swift 4.2 comes with Xcode 10.0 beta, and among other goodies includes some changes to how protocols apply to arrays. I've just updated an earlier post on this (Is serializable really a word?), but it's worth repeating here: this is exciting stuff. Now, with the single line:

extension Array: Serializable where Element: Serializable {}

…the Serializable protocol I wrote applies to all arrays of Serializable elements. That is so clean it is to my eyes simply beautiful. Testament to a lot of hard work.

This info come via the talk "What's new in Swift?", worth watching as as ever are all the other WWDC videos.