Scala println in a for loop

Posted by random459 on Stack Overflow See other posts from Stack Overflow or by random459
Published on 2010-03-14T11:43:10Z Indexed on 2010/03/14 11:45 UTC
Read the original article Hit count: 245

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about scala

Related posts about print