lua-users home
lua-l archive

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


2010/12/20 Michal Kottman <k0mpjut0r@gmail.com>:
> 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
>
>
>
>
but what if I don't know the amount of multi return values?