Created
January 28, 2019 12:28
-
-
Save salmaanahmed/4ea9da14a1485a35c99065c72e67daaf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let d: [String: String?] = ["a": "1", "b": nil, "c": "3"] | |
let r1 = d.filter { $0.value != nil }.mapValues { $0! } | |
let r2 = d.reduce(into: [String: String]()) { (result, item) in result[item.key] = item.value } | |
// r1 == r2 == ["a": "1", "c": "3"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment