Last active
June 6, 2016 20:17
-
-
Save jayrhynas/d46026fbbebe88b2e701e1283412dc5f 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
func checkAll<T1, T2, T3>(clauses: (T1?, T2?, T3?)) -> (T1, T2, T3)? { | |
guard let one = clauses.0 else { | |
print("1st clause is nil") | |
return nil | |
} | |
guard let two = clauses.1 else { | |
print("2nd clause is nil") | |
return nil | |
} | |
guard let three = clauses.2 else { | |
print("3rd clause is nil") | |
return nil | |
} | |
return (one, two, three) | |
} | |
let a: Int? = 0 | |
let b: Int? = nil | |
let c: Int? = 3 | |
guard let (d, e, f) = checkAll((a, b, c)) else { | |
fatalError() | |
} | |
print("a: \(d)") | |
print("b: \(e)") | |
print("c: \(f)") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment