That's because it's two different ways of doing the same thing. The first
is just more compact, and does not give you access to the reader, where as
the second gives you access to the reader and allows you to do various
things with it.


Best regards / Med venlig hilsen,
Søren Berg Glasius

Hedevej 1, Gl. Rye, 8680 Ry, Denmark
Mobile: +45 40 44 91 88, Skype: sbglasius
--- Press ESC once to quit - twice to save the changes.

On 7 August 2015 at 12:53, Mauro Sanna <mrsan...@gmail.com> wrote:

> It's not clear to me what's the difference between:
>
> file1.eachLine() { println it }
>
> and
>
> file1.withReader { reader ->
>     while ((line = reader.readLine()) != null) {
>         println line
>     }
> }
>
> the output is the same.
> Thank you.
>

Reply via email to