Question:

What output will be produced by the code below?

let i = 3

switch i {
case 1:
    print("Number was 1")
case 2:
    print("Number was 2")
case 3:
    print("Number was 3")
}

Answer:

Correct answer: This code will not compile.

Explanation: Swift requires all switch statements to be exhaustive. This code will not compile because it does not have a default clause.


Keywords:

© 2017 QuizBucket.org