Created
November 19, 2014 15:27
-
-
Save apparentsoft/6ab276fe2befa7151fb6 to your computer and use it in GitHub Desktop.
IfLetTuples.swift
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
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