Skip to content

Instantly share code, notes, and snippets.

@jayrhynas
Last active June 6, 2016 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jayrhynas/d46026fbbebe88b2e701e1283412dc5f to your computer and use it in GitHub Desktop.
Save jayrhynas/d46026fbbebe88b2e701e1283412dc5f to your computer and use it in GitHub Desktop.
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