0

Order of println() and readLine() in Kotlin

Here's my simple code: fun main(args: Array<String>) { println("Write your name: ") var name = readLine()!!.toString() println("Your name is: "+name) } When i run program, it asking for input by popup Window "Seems like your program requires an input" first, and after i submit my name it shows two lines together: "Write your name: Your name is: John" It should be rather: 1. "Write your name: " 2. then input my name by readLine() 3. Output my name Am I missing something? I am very beginner :)

11th Apr 2023, 1:21 PM
Slawoo
3 Respuestas
+ 5
Yes, this is the order that one would expect when running the code on one's own computer. Sololearn Kotlin playground, however, is not interactive. We need to submit all input in the beginning of the program. Multiple inputs are separated by linebreaks (also note the little text in the pop-up window).
11th Apr 2023, 1:33 PM
Lisa
Lisa - avatar
+ 1
Thank you.
11th Apr 2023, 2:28 PM
Slawoo
0
If you go to kotlinlang.org there's a link to get intellij IDEA. A pretty nice free ide for kotlin or Java
12th Apr 2023, 12:33 AM
Bob