If I assign values from readln() successively, they do not work properly; the second variable is an empty line.
fun main() {
val first = readln()
val second = readln()
println(first)
println(second)
}
Does the second variable reads in some empty string or changeLine thing? If I switch the order of line 3 and line 4, everything just works fine.
fun main() {
val first = readln()
println(first)
val second = readln()
println(second)
}
Just wondering what happened in the first code?
edit : I tried this in Intellij community under Win11 and Ubuntu in VMware. Here is the picture: console debug I ran the code by left-clicking the green triangle.
edit: the first code worked fine on my old laptop, but after I updated my Intellij to the latest version, the first code broke as well.
CodePudding user response:
In 2022.1.1 there is some bug in the console causing readLine (among other readers) to skip user input. [1] This bug is fixed in 2022.1.2 Preview. [2] Oddly, the problem seems to persist in 2022.2 EAP.