I tried it like this:
var index: Int = 0
var foundMessage: Bool = false
while foundMessage == false {
foundMessage = aliceMessages[index].contains("Caterpillar")
index += 1
if foundMessage {
print()
}
}
print(index - 1)
But I don't think that it should look like this. Also it should've been written with while loop, so it cannot be done by for in with break.
Topic:
Programming Languages
SubTopic:
Swift
Tags: