[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Forward function declarations - relocal command
- From: Dirk Laurie <dirk.laurie@...>
- Date: Tue, 20 Nov 2012 16:17:38 +0200
2012/11/20 David Favro <lua@meta-dynamic.com>:
> local rv1;
> repeat
> local rv2;
> rv1, rv2 = foo();
> until rv2;
> -- use rv1 here...
> Is there some other idiom to accomplish this in the current language
> with a nicer look than my first snippet?
If the only purpose of rv2 is to drive the loop, then:
Inside foo(): instead of
return rv1, rv2
put
if ~rv2 then return rv1 end
Then the calling code becomes:
local rv1
for v in foo() do
rv1=v
end
I