To follow up on what Soren said... The first one is a 'convenience method'; it's provided as a shortcut to provide a simple and fast way to output.
The second is the long way of doing it and provides additional functionality. Owen Rubel 415-971-0976 [email protected] On Fri, Aug 7, 2015 at 4:30 AM, Søren Berg Glasius <[email protected]> wrote: > 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 <[email protected]> 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. >> > >
