lua-users home
lua-l archive

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


Hi Xmilia,

Thank you for the quick answer.

Best,
Bachir

On Sat, Sep 30, 2023 at 7:53 AM Xmilia Hermit <xmilia.hermit@gmail.com> wrote:

I know that the three dots notation '...' can be used in function definition to mean variable arguments. My question is: Is it legal to have the three dots _expression_ as an argument to a function call?

Yes, the three dots are allowed to be used in variadic functions as expressions and result in the arguments passed in the variadic part (see https://www.lua.org/manual/5.4/manual.html#3.4).

For example:

function pass_on(func, ...)
   return func(...)
end

will take a function and more aguments and call the function with all the passed arguments after the func argument.

Regards,
Xmilia