Skip to content

Instantly share code, notes, and snippets.

@hachinobu
Created September 27, 2015 13:21
Show Gist options
  • Save hachinobu/e417f99cbf3caec07ffa to your computer and use it in GitHub Desktop.
Save hachinobu/e417f99cbf3caec07ffa to your computer and use it in GitHub Desktop.
OptionalSwift2.0
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