On Tue, Apr 22, 2003 at 03:39:38AM +0900, Bill Kelly wrote:
> Hi,
> 
> One difference between
> 
> >   lines = IO.readlines(file)
> 
> and
> 
> >   lines = File.open(file).readlines
> 
> is that, I think, IO.readlines is handling closing the file 
> for you, whereas the latter is relying on the garbage collector
> to (eventually) close the file?

True. But since File inherits from IO, the first example could be written

    lines = File.readlines(file)

anyway, which solves the dilemma of "when to use IO and when to use File".

What's not clear to me is why IO has a class method which is able to open
files by name. There is no IO.open so why is there IO.readlines? But I see
there is IO.reopen. Hmm, the division of responsibility between IO and File
seems a bit blurred to me...

Regards,

Brian.