« Return to Thread: Source.fromFile(file).getLines

Re: Source.fromFile(file).getLines

by Daniel Sobral :: Rate this Message:

Reply to Author | View in Thread

No, not expected. I don't get that either. Try doing map(_ map(_ toInt)) to the result of getLines. Maybe you are getting "\r\n" and confusing it with "\n\n".

On Thu, Jul 9, 2009 at 1:38 PM, Gilles SCOUVART <Gilles.SCOUVART@...> wrote:
Hello all,
 
I was surprised to notice that using Source.fromFile(file).getLines on a file with empty lines, those were added to the previous non empty line.
I.e. if the file contains this:
------
test
 
 
------
then getLines.next would return "test\n\n" (written java-echap-style).
I expected it would iterate on three lines instead: "test", "", and "".
This is a little bit annoying for pattern matching on full lines...
 
Is this expected behaviour?
 
Gilles Scouvart.



--
Daniel C. Sobral

Something I learned in academia: there are three kinds of academic reviews: review by name, review by reference and review by value.

 « Return to Thread: Source.fromFile(file).getLines