[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Is breaking out of io.lines(file) safe?
- From: "Robert G. Jakabosky" <bobby@...>
- Date: Fri, 18 Mar 2011 15:18:23 -0700
On Friday 18, mitchell wrote:
> I want to iterate over the lines in a file, but break out if a certain
> condition is true. The documentation says the EOF is detected and the file
> is closed. If I break before the EOF is detected, is the file not closed?
> I don't want to leave open file references in my Lua state.
> for line in io.lines(filename) do
> if condition then break end
local file = io.open(filename)
for line in file:lines() do
if condition then break end
Robert G. Jakabosky