error when running readInt
Closed this issue · 2 comments
SimFar commented
when running the following simple code, an error occurs. My system is win10.
import io.StdIn
val r = StdIn.readInt
error (from the log)
Problem
java.io.EOFException: Console has reached end of input
at scala.io.StdIn.readInt(StdIn.scala:120)
at scala.io.StdIn.readInt$(StdIn.scala:117)
at scala.io.StdIn$.readInt(StdIn.scala:241)
at Wrapper3$.(scripteditor:13)
at Wrapper3$.(scripteditor)
at Wrapper3.entry(scripteditor)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
litan commented
Kojo does not have an attached Console, so the StdIn stuff will not work. Instead, use Kojo's built-in readXX methods. For example:
val r = readInt("Enter a number")
Kojo supports readInt(prompt)
, readDouble(prompt)
, and a generic readln(prompt)
.
SimFar commented
ths, it works.