When using the Lua 5.2 API, the code below prints "nil"
function __debug(szName, ...)
print(type(arg));
end
__debug("s", 1, 2, 3, 4);
But this code does work when using Lua 5.1, and prints "table"
If you are referring to vararg function, the arg
table was deprecated already in Lua 5.1. In Lua 5.2, you can use table.pack
to create arg
if you need it:
function debug(name, ...)
local arg = table.pack(...)
print(name)
for i=1,arg.n do
print(i, arg[i])
end
end
That's because arg
has been deprecated since Lua 5.1. It only remained as a compatibility feature.
References: Lua 5.1 manual, unofficial LuaFaq
a workaround is using this line to generate a table called arg:
local arg={...}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With