Missing "toInt()" from string after upgrading Kotlin

1k views Asked by At

Any suggestion on how to troubleshoot this?

enter image description here

2

There are 2 answers

1
Umar zzstu Syed On

If you are planning on changing that digit or using it more than once, I would recommend making it a val or var. And the .toInt is available.

fun main() {
var number = "1"
val printThis = number.toInt()
println(printThis)

}

0
Vadim Hagedorn On

This could be an IntelliJ issue. Does the program compile with Gradle?

Assuming the former, try re-installing and/or updating the Kotlin plugin for IntelliJ. Also, try clearing caches via File > Invalidate Caches ... > Invalidate and Restart