Question:

What output will be produced by the code below?

let names = ["Chris", "Joe", "Doug", "Jordan"]

if let name = names[1] {
    print("Brought to you by \(name)")
}

Answer:

 

Correct answer: This code will not compile.

Explanation: Subscripting an array of strings will return a String rather than a String?, which means it is a compile error to attempt to unwrap it using if let.

 


Keywords:

© 2017 QuizBucket.org