Skip to content

Instantly share code, notes, and snippets.

@sssbohdan
Created May 3, 2021 07:13
Show Gist options
  • Save sssbohdan/8c96ad736bf2311286a06d45827b882c to your computer and use it in GitHub Desktop.
Save sssbohdan/8c96ad736bf2311286a06d45827b882c to your computer and use it in GitHub Desktop.
Flatten exampe 1
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