Swift - Optionals
What will be the output of the following Swift code?
let x: Int? = 5
let y: Int? = nil
if let a = x, let b = y {
print(a + b)
} else {
print("Failed to unwrap")
}What will be the output of the following Swift code?
let x: Int? = 5
let y: Int? = nil
if let a = x, let b = y {
print(a + b)
} else {
print("Failed to unwrap")
}x has value 5, but y is nil.y is nil, the if let fails and the else block runs.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions