Created
September 27, 2015 13:21
-
-
Save hachinobu/e417f99cbf3caec07ffa to your computer and use it in GitHub Desktop.
OptionalSwift2.0
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
let someOptional:Int? = 42 | |
if case .Some(let x) = someOptional{ | |
print("someOptional value is \(x)") | |
} | |
if case let x? = someOptional{ | |
print("someOptional value is \(x)") | |
} | |
let arrayOptionalInts:[Int?] = [nil,1,2,3,nil,5] | |
for case let number? in arrayOptionalInts where number > 2 { | |
print("Found a \(number)") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment