[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Is breaking out of io.lines(file) safe?
- From: Roberto Ierusalimschy <roberto@...>
- Date: Sat, 19 Mar 2011 17:13:07 -0300
> Yes, the file handle will still be open, at least until the file
> object is garbage collected. There is no way for an iterator to detect
> a broken loop and run cleanup code, so you will need to make sure the
> handle is closed explicitly.
Or simply leave it to the garbage collection. (More often than not there
is no hurry to close the file.)
-- Roberto