[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: unpack, pcall, nil
- From: Shaun McVey <shaun.mcvey@...>
- Date: Mon, 21 Sep 2009 02:39:57 +0100
You probably want to drop the unpack:
function doit(...)
local status, err = pcall(...)
-- do something with status and err
end
On Mon, Sep 21, 2009 at 2:37 AM, Luiz Henrique de Figueiredo
<lhf@tecgraf.puc-rio.br> wrote:
>> function doit()
>> local status, err = pcall(unpack(arg))
>> -- do something with status and err
>> end
>>
>> and
>>
>> doit(x, arg1, arg2, ...)
>>
>> Now the problem is arg1, arg2 etc can genuinely be nil, and unpack stops at nil. Is there any way I can get unpack to get all the entries in the table, whether or not they are nil? Thanks,
>
> use "..." instead of arg:
>
> function doit(...)
> local status, err = pcall(unpack(...))
> -- do something with status and err
> end
>