Scala IO Read lines

65 views
Skip to first unread message

Trond Olsen

unread,
Apr 7, 2011, 4:57:35 AM4/7/11
to scala-i...@googlegroups.com
Hi, I did a little inital testing of the IO API for reading text files. I like how Path is structured and how easy it is to handle the file you're refering to. One improvement I'd like to see though is the lines() function which require arguments. Is it possible do some defaulting here in regard to terminators?

Jesse Eichar

unread,
Apr 7, 2011, 11:48:33 AM4/7/11
to scala-i...@googlegroups.com
As a matter of fact lines() does take parameters. You can choose the
type of line terminator and if the terminator should be included or
not.

I will add some examples to the documentation that demonstrates lines.

Jesse

Paul Phillips

unread,
Apr 7, 2011, 12:02:05 PM4/7/11
to scala-i...@googlegroups.com, Jesse Eichar
On 4/7/11 8:48 AM, Jesse Eichar wrote:
> As a matter of fact lines() does take parameters. You can choose the
> type of line terminator and if the terminator should be included or
> not.
>
> I will add some examples to the documentation that demonstrates
> lines.

I think he understands that it takes parameters, and wants to not have
to supply any. Since it appears to have defaults for all the
parameters, the piece of knowledge missing is that you can't leave the
parens off completely when a method has default arguments. This was
done to stave off some ambiguous scenarios. It's less than ideal but
probably not changing anytime soon.

Josh Suereth

unread,
Apr 7, 2011, 12:43:46 PM4/7/11
to scala-i...@googlegroups.com, Paul Phillips, Jesse Eichar
Unless you make the arguments implicit, in which case, you're inviting the racoons in to feast.

Trond Olsen

unread,
Apr 7, 2011, 10:40:49 PM4/7/11
to scala-i...@googlegroups.com, Jesse Eichar
Like Paul said, I was looking for a lazy way. :) Some examples will be nice. I noticed when using File API that it doesn't reference the Core API. Is it possible to link them up so you don't need to do manual lookup? Like for instance, when browsing Path.lines() you see it need the manually look up Terminator.

Jesse Eichar

unread,
Apr 9, 2011, 1:05:04 AM4/9/11
to Trond Olsen, scala-i...@googlegroups.com
On Fri, Apr 8, 2011 at 4:40 AM, Trond Olsen <tr...@steinbit.org> wrote:
Like Paul said, I was looking for a lazy way. :) Some examples will be nice. I noticed when using File API that it doesn't reference the Core API. Is it possible to link them up so you don't need to do manual lookup? Like for instance, when browsing Path.lines() you see it need the manually look up Terminator.


I should be able to link the two APIs up but I don't know SBT good enough yet to do it.  I would guess there is a scaladoc option to do that but will have to look into it.  As for examples, this question made me add some new examples which you can see at: http://jesseeichar.github.com/scala-io/core/lines/index.html

Jesse
Reply all
Reply to author
Forward
0 new messages