未解决的参考:计数错误(科特林函数)

ah

我正在学习科特林,并且正在科特林创建的游乐场玩耍。当我按照演示练习进行操作时,出现了这些错误。“未解决的参考:计数”“未解决的参考:计数”
我不明白为什么,因为我完全模仿了网站上示例中的演示。

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"
}
劳伦佐

您必须count先在函数中使用它,然后再定义它,例如var count = ...

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章