Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Interactive Kotlin Playground Option #226

Open
mirianfonkam opened this issue Jan 8, 2025 · 0 comments
Open

Feature Request: Interactive Kotlin Playground Option #226

mirianfonkam opened this issue Jan 8, 2025 · 0 comments

Comments

@mirianfonkam
Copy link

Feature Request

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

Links to similar discussions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant