1

The reference pages all say things like

function this(...)
end

However when I try to apply the supposed arg variable all I get is a nil reference. Any attempt I've made to capture the arguments results in a nil table. I've tried forcing a local tab = {...} and still get the nil reference. The closest I've managed to get to capturing the arguments is a select("#",...) which only returns the number of arguments. Whenever I try to capture this outside parameter declaration I get nothing but another error...

I've been thoroughly looking into this with no avail... any way I can accomplish this without forcibly passing a table?

0

1 Answer 1

4

The arg argument is for Lua 5.0 only. Since Lua 5.1, the vararg expression ... is used instead.

Try this:

function foo(...)
    for k, v in ipairs{...} do
        print(k, v)
    end
end

foo('hello', 'world')
Sign up to request clarification or add additional context in comments.

1 Comment

strange...it wasn't working in the slightest last night but now it's working just fine...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.