Skip to content

Instantly share code, notes, and snippets.

@apparentsoft
Created November 19, 2014 15:27
Show Gist options
  • Save apparentsoft/6ab276fe2befa7151fb6 to your computer and use it in GitHub Desktop.
Save apparentsoft/6ab276fe2befa7151fb6 to your computer and use it in GitHub Desktop.
IfLetTuples.swift
func noNils(optionals:[Any?]) -> Bool {
for item in optionals {
if item == nil {
return false
}
}
return true
}
func allSome<A,B>(a:A?, b:B?) -> (A,B)? {
switch (a,b) {
case (.Some(let aa), .Some(let bb)):
return (aa,bb)
default:
return nil
}
}
func allSome<A,B,C>(a:A?, b:B?, c:C?) -> (A,B,C)? {
switch (a,b,c) {
case (.Some(let aa), .Some(let bb), .Some(let cc)):
return (aa,bb,cc)
default:
return nil
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment