Home > Enterprise >  Unresolved reference: readln - in InteliJ IDEA
Unresolved reference: readln - in InteliJ IDEA

Time:02-17

this code in a new project throws "Unresolved reference: readln" error

fun main() {
    val z = readln()
}

But on another project in Intelij IDEA works ok. Why so?

enter image description hereenter image description here

CodePudding user response:

readln() was added in Kotlin 1.6. Make sure you are using Kotlin 1.6 or later.

CodePudding user response:

The readln function is only available since version 1.6.0 of Kotlin, see it's documentation

Most likely the other project uses an older version of Kotlin, in which this function was not available yet.

CodePudding user response:

thanks!

I had to go to Preferences -> Languages & Frameworks -> Kotlin - and change Update channel from "Stable" to Early Access Preview 1.6.x or 1.7.x

  • Related