Swift Optionals
An optional type, written Int?, either holds a value or holds nil. Int("42") returns an Int? because the text may not be a number. Swift forces you to deal with the possibility of nil before using the value.
Swift
let values = ["42", "x7"]
for text in values {
if let number = Int(text) {
print("number \(number + 1)")
} else {
print("not a number: \(text)")
}
}