更新时间:2022-11-11 11:56:05
预期返回字符串"的函数中缺少返回
Missing return in a function expected to return 'String'
应该函数 return
什么,因为你没有设置 return
如果不匹配任何一个 question.hasPrefix()
should the function return
something , because you did not set return
if do not match any one question.hasPrefix()
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"
}
return "something"
}