I have this code. How to make it jump out of while...
# announcements
m
I have this code. How to make it jump out of while loop? I mean what should be input? I have entered nothing and just pressed the enter button but it takes it as string. And I also tried 0 and it did not work. "this line" never being printed to console. any ideas?
Copy code
fun main(args: Array<String>) {
    var line = readLine()
    while (line !=null) {
        println(line)
        line = readLine()
    }
    println("this line")
}
m
Try
Ctrl + D
m
I wanted something in code. I guess my code is for the time you are getting your input from file ...
s
while (line.isNotEmpty()) { … }
?