ReadInt for scala.io.Source

In Console.scala , we have some nice methods like readInt, readCharetc.

Why don't we have them for io.Source? And if you say that we should use the capabilities of Java IO, then why using methods Console.read*?

Any other scala -ish method for a minimal file parser?

+3
source share
2 answers

I'm not sure if it's worth adding this to the standard library. Console.readIntreads an entire line and then converts it to int. Presumably, an example use is when a user is prompted to enter an integer on the console. It is also not encoded in a protective way, try entering a space after the number, for example'6 '

readChar , .

io.Source - char . , Console.read*, .

, , .

+1

:

val sc = new java.util.Scanner (System.in)
+2

All Articles