Rizwan Ahmed
1 min readDec 28, 2018

--

Hi Max Howell,

Well you see, installing the Swift 5 toolchain will allow you to use Swift 5 related syntax by default. Make sure that you have switched the toolchain before trying the new syntax. I am not sure why Xcode isn’t suggesting the language version in the build settings. (Remember it is a development snapshot, not the final version!).

For testing whether our new toolchain works or not we will try to implement a code snippet which uses compactMapValues. CompactMapValues is available only from Swift 5.

Code snippet:

let dictonary: [String: String?] = ["Apple": "1", "Orange": nil, "Mango": "2"]
let result = dictonary.compactMapValues({$0})
//result = ["Apple" : "1", "Mango" : "2"]

Reference :

https://github.com/apple/swift-evolution/blob/master/proposals/0218-introduce-compact-map-values.md

--

--

Rizwan Ahmed
Rizwan Ahmed

Written by Rizwan Ahmed

iOS Engineer @zoho , Creator — http://ohmyswift.com Support OhMySwift by buying us a pizza! 👉 https://buymeacoffee.com/ohmyswift

No responses yet