The following Scala code does just what I expect it to - it prints each line of some_file.txt.
import scala.io.Source
val lines = Source.fromPath("some_file.txt").mkString
for (line <- lines) print(line)
If I use println instead of print, I expect to see some_file.txt printed out with double-spacing. Instead, the program prints a newline after every character of some_file.txt. Could someone explain this to me? I'm using Scala 2.8.0 Beta 1.
.mkString
on the result offromPath
, which is anIterator[Char]
with some added stuff. I know you know this, but I think you could make it clearer. You could also put an example of a for comprehension over aString
literal. – Watcher