[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: what's wrong with this loop syntax?
- From: "Michael Newberry" <mnewberry@...>
- Date: Mon, 8 Jan 2007 15:24:45 -0700
It would be nice if one or more assignments could be evalulated but ignored
left to right, so long as there is a value to test before "do":
while <assignment>, str ~= nil do
--[code]
end
or just evaluate str rather than str ~= nil.
Michael
----- Original Message -----
From: "Antony Sidwell" <antony@isparp.co.uk>
To: "Lua list" <lua@bazar2.conectiva.com.br>
Sent: Monday, January 08, 2007 2:37 PM
Subject: Re: what's wrong with this loop syntax?
Michael Newberry wrote:
Luiz, OK, thanks. Is there any way to make it more compact (and more
readable to me, at least), where the loop is tested at the top of the
loop? Here is what I use:
while true do
str = S:Next()
if str == nil then break end
-- [code]
end
I think I generally use something like:
str = S:Next()
while str do
-- [code]
str = S:Next()
end
which is no more compact, but I prefer it anyway, especially for a simple
"next" assignment like that.
--
Antony Sidwell