I encountered the following code in a project that I’m working with. i don’t understand the iteration part of for-loop. What is the select() function?
function _log (str,...)
local LOG="/tmp/log.web"
for i=1,select('#',...) do
str= str.."\t"..tostring( select(i,...) )
end
os.execute("echo \"".. str .."\" \>\> " .. LOG )
end
From the Lua manual:
From this post on Lua’s multiple arguments and the "select" function, you can convert into a table if you really need to:
Finally, if you pass "#" as index, the function returns a count of the multiple arguments provided: