Question:

What output will be produced by the code below?

let names = ["Serenity", "Sulaco", "Enterprise", "Galactica"]

for name in names where name.hasPrefix("S") {
    print(name)
}

Answer:

 "Serenity", "Sulaco".

Explanation: The where condition for the loop will ensure that only names that start with the letter S will used inside the loop.

 


Keywords:

© 2017 QuizBucket.org