Пожалуйста, прочитайте комментарии, которые я добавил в блок кода
struct MyQuestionAnswerer {
func responseTo(question: String) -> String {
let question = question.lowercased() // <- Converts all the strings in your question into lower case
let defaultNumber = question.count % 3
if question == "hello there" {
return "Why hello there"
} else if question == "where should I go on holiday?" { // <- I is upper case
return "To the North!"
} else if question == "where can I find the north pole?" { // <- I is upper case
return "To the North!"
} else if question == "where are the cookies?" {
return "In the cookie jar!"
} else if defaultNumber == 0 {
return "That really depends"
} else if defaultNumber == 1 {
return "Ask me again tomorrow"
} else {
return "Could be anything"
}
}
}
Так что, по сути, вы сравниваете "где следует i ... "to" где следует I ... ", поскольку это сравнение ложно и не соответствует ни одному другому блоку, оно проваливаетсядо последнего блока еще.