[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANNOUNCE] Lua 5.0 (work0)
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 12 Jun 2002 09:18:23 -0300
> but is there a simpler way than this to read the lines from a file:
> [...]
I think a good solution would be something like
function lines (filename)
local f = assert(io.open(filename, "r"))
return function ()
return f:read() or (assert(f:close()) and nil)
end
end
so that we could use it without any other "preparation":
for line in lines(file) do ... end
But I'm not sure whether such function belongs to the `io' lib or to
some extension library.
-- Roberto