Created
December 23, 2014 20:41
-
-
Save jrturton/decdce06e81b48441c4f 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
import Foundation | |
func coalesce<T>(args: T?...) -> T? { | |
for possible in args { | |
if let actual = possible { | |
return actual | |
} | |
} | |
return nil | |
} | |
var optional1 : Int? | |
var optional2 : Int? | |
var optional3 : Int? | |
optional2 = 1 | |
if let valid = coalesce(optional1,optional2,optional3) { | |
println(valid) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment