Last active
November 6, 2019 12:28
-
-
Save PaulTaykalo/2ebfe0d7c1ca9fff1938506e910f738c to your computer and use it in GitHub Desktop.
This file contains hidden or 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 a: Double? = 1.0 | |
let b: Double? = 2.0 | |
let c: Double? = 3.0 | |
let d: Double? = 4.0 | |
let e: Double? = 5.0 | |
let f: Double? = 6.0 | |
let g: Double? = 7.0 | |
extension Optional { | |
func `or`(_ value : Wrapped?) -> Optional { | |
return self ?? value | |
} | |
func `or`(_ value: Wrapped) -> Wrapped { | |
return self ?? value | |
} | |
} | |
//let result = a ?? b ?? c ?? d ?? e ?? f ?? g ?? 1.0 // <--- This will fail to compile | |
let result = a.or(b).or(c).or(d).or(e).or(f).or(g).or(1.0) // <--- This will not | |
print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Basically the problem is the type checker constrain solver.