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
see an associated block, it doesn't handle the cleanup for you.
The "block inside block" version guarantees cleanup, even if an
exception is thrown.

Other than that, I think your suggestions are good.

--Wilson.