readLine() only reads second input in console

Viewed 456

I'm just getting started with Kotlin, so I apologize if it's a dumb problem (which I think it probably is).

I'm following this guide, but ran in an issue: the readLine function ignores my first input, and returns only the second line I insert.

fun main() {
    println("What's your name?")
    val name= readLine()
    println("Hello $name!")
}

And this is the output I'm getting (">" marks my input into the console):

What's your name?
> Paul
> John
Hello John!

I'm using IntelliJ IDEA Community 2020.2, if that makes a difference. Thanks in advance for any help!

0 Answers
Related