lua-users home
lua-l archive

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





On Wed, May 28, 2014 at 11:28 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
2014-05-28 17:23 GMT+02:00 Marc Balmer <marc@msys.ch>:
>
> Am 28.05.2014 um 12:52 schrieb Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>:
>
>>> local args = ...
>>
>> This only gets the first argument.
>> To get them all, so that you can loop over them, use
>>       local arg={...}
>>
>
> So
>
> a, b, c = ...
>
> will not work for pcall(script, 1, 3, 3) ?

If you know how many arguments you can use, that
is perfect. Luiz's point is that if you don't, your easiest
recourse is a table constructor.

And, because it wasn't mentioned, there is always `select`. For example...

print("I received ", select('#', ...), "arguments")

for i = 1, select('#', ...) do
   print(
      ("The %d argument is:\t '%s' (%s)"):format(
         i,
         tostring(select(i, ...)), 
         type(select(i,...))
      )
   )



Andrew