I am newly learning kotlin, and I am playing in the Playground that kotlin created. As I was following the demo practice, I got these errors. "Unresolved reference: count" "Unresolved reference: count"
I don't understand why because I exactly mimicked the demo that is in the Example on the website.
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)
Also,
fun generateAnswerString(countThreshold: Int): String = if (count > countThreshold) {
"I have the answer"
} else {
"The answer eludes me"
}
You gotta define count
before using it in your function, like var count =...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.