-
-
Save lilyball/d6d0444f9838052f1a08 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
extension Optional { | |
func and<U>(x:U?) -> (T, U)? { | |
switch (self, x) { | |
case let (.Some(a), .Some(b)): | |
return (a, b) | |
default: | |
return nil | |
} | |
} | |
} | |
var x : Int? | |
var y : Int? | |
x = 5 | |
y = 60 | |
if let (a, b) = x.and(y) { | |
println("\(a), \(b)") | |
} else { | |
println("nope") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment