Created
May 3, 2021 07:13
-
-
Save sssbohdan/8c96ad736bf2311286a06d45827b882c to your computer and use it in GitHub Desktop.
Flatten exampe 1
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
var dict = [Int: Int?]() | |
let val = dict[0] // Int?? | |
func f(_ optionalInt: Int?) -> Int { optionalInt ?? 0 } | |
//f(val) // compiler error | |
f(val.flatten()) // works |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment