1
我想添加编辑从苹果的QuestionBot一些代码。我想出了这个:Swift错误:缺少返回函数预计返回'字符串'
func responseToQuestion(question: String) -> String {
if question.hasPrefix("hello") {
return "Hello"
} else if question.hasPrefix("where") {
return "There"
} else if question.hasPrefix("what"){
return "I don't know"
}
}
但有一个错误:缺少返回的函数预计返回'字符串'。我该怎么办,谢谢?
想想看:我应该如果这个问题有没有这三个前缀的函数返回? –
我明白了。谢谢! – Luka