[英]Unresolved reference: count error (Kotlin Function)
我正在學習 kotlin,我正在 kotlin 創建的 Playground 中玩耍。 在我進行演示練習時,我遇到了這些錯誤。 “未解決的引用:計數” “未解決的引用:計數”
我不明白為什么,因為我完全模仿了網站上示例中的演示。
fun generateAnswerMachine(countThreshold: Int): String {
val answerMachine = if (count < countThreshold) {
"I have the answer."
} else {
"The andswer eludes me"
}
return answerMachine
}
val answerString = generateAnswerMachine(42)
還,
fun generateAnswerString(countThreshold: Int): String = if (count > countThreshold) {
"I have the answer"
} else {
"The answer eludes me"
}
在 function 中使用它之前,您必須定義count
,例如var count =...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.