On Wed, 14 Sep 2005, Wilson Bilkovich wrote:

> On 9/12/05, Hugh Sasse <hgs / dmu.ac.uk> wrote:
>>>    File.open(file, "rb") do |io|
>>>      io.each_line do |line|
>>
>> Coould do that in one I think
>>       File.open(file, 'rb').each_line do |line|
>> because you don't use io again.
>>
> I used this form frequently in the past, but then someone explained to
> me that it never closes the file handle.  Because File.open doesn't

Good point.

> see an associated block, it doesn't handle the cleanup for you.

Yes, that's right.  I wonder if it is worth the price in garbage
collection to explicitly close in this case?   Probably not given
maintenance costs.

> The "block inside block" version guarantees cleanup, even if an
> exception is thrown.

Exceptions are another good point!

>
> Other than that, I think your suggestions are good.

Did they help at all?
>
> --Wilson.
>
         Hugh