Question:

How many lines will be printed by the code below?

import Foundation

let data: [Any?] = ["Bill", nil, 69, "Ted"]

for datum in data where !(datum is Hashable) {
    print(datum)
}

Correct answer: 1.

Explanation: The loop will print only items that do not conform to the hashable protocol. In this code, the only such item is nil, so one line will be printed.

 


Keywords:

© 2017 QuizBucket.org