Lua: use table as args

I have numerous functions (unknown during development), each of which takes a certain number of arguments. I have an argument table. How can I call these functions this argument table?

Thanks James

+4
source share
1 answer

Use unpack() :

 function test(a,b,c) print(a+b+c) end myargs = {1,2,3} test(unpack(myargs)) -- prints "6" 
+14
source

All Articles