lua-users home
lua-l archive

Re: how to store multi return value provisionally?

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, 2010年12月20日 at 20:48 +0800, starwing wrote:
> i.e. i want to do that:
> 
> ??? = coroutine.resume(...)
> if ???[1] then
> --- do something with ???[1...]
> else
> --- do something with ???[1...]
> end
> 
> but I don't want to use table, I just wonder it's possible to
> implement it just operate the multi-values itself.
Create locals from them. For example, if your thread yields 3 values:
local ok, val1, val2, val3 = coroutine.resume(...)
if ok then
 -- do something with 'val1', 'val2', 'val3'
else
 -- 'val1' is the error message, process it
end

AltStyle によって変換されたページ (->オリジナル) /