You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the Kotlin Playground does not support standard input directly. Meaning that running the following code will not work:
val number = readln()
println("You entered: $number")
It will throw Exception in thread "main" kotlin.io.ReadAfterEOFException: EOF has already been reached at kotlin.io.ConsoleKt.readln (Console.kt:152).
This feature would be add more interactivity for the playground. This will be specially helpful for beginners. A solution could be to show a pop up dialog for input.
Some workarounds for this issue is to create a custom function with stubbed input, or use readlnOrNull() (e.g. readlnOrNull() ?: "this is a simulated input", or to put arguments in the argument box, have the signature fun main(args: Array<String>) and call args.first(). My favorite workaround is using JS on playground as suggested in this answer: https://stackoverflow.com/a/73898805
Feature Request
Currently, the Kotlin Playground does not support standard input directly. Meaning that running the following code will not work:
It will throw
Exception in thread "main" kotlin.io.ReadAfterEOFException: EOF has already been reached at kotlin.io.ConsoleKt.readln (Console.kt:152)
.This feature would be add more interactivity for the playground. This will be specially helpful for beginners. A solution could be to show a pop up dialog for input.
Links to similar discussions
The text was updated successfully, but these errors were encountered: