In this question, it was suggested to use Console.in.read.toChar
. It works fine in REPL, but fails to work when I put it into a script (requires user to press Enter):
#!/usr/bin/scala
!#
while (true) {
val c = Console.in.read.toChar
println("Got " + c)
}
So when I type a char and press Enter, I get
Got a
Got
I'm using Scala 2.9.0.1, on Ubuntu 11.04, in gnome-terminal.
What am I doing wrong?