lua-users home
lua-l archive

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



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