Multiple arguments in a function issues "..."

Hello, I would like to know if this is correct or how I can use multiple arguments in a function, could you give me an example or how to correct the one I already did?

   local function do_something (...)
        local c = ...
    end

    do_something(print("dsdsd", "dsdsds", true, "safsadf"))

If you want to split the arguments into different variables, you can use local a, b, c = ... for one instance. Otherwise you can contain it in a table.

1 Like

Do you think you could give me an example in a table and in a variable, please :frowning:

You can actually contain it by using this:
local args = {...}

Something like this? Is it good? :open_mouth:

local function using_table (...)
    local args = {...}
end

local function using_var (...)
    local var = ...
end

using_table("text1", true, "text2")
print(using_table)

using_var("text", true, "text2")
print(using_var)

Something like this:

local function get_varargs_table(...)
   return {...} -- returns a table with the arguments passed
end

local function get_varargs_raw(...)
   return ... -- returns all of the arguments that were passed (without a table)
end

print(get_varargs_table("this", "is", "a string", "+", 0))
print(get_varargs_raw("this will print", "all of these arguments"))
2 Likes

Great, this is what I was looking for! but why not print this part?
image

Oh, I was under the impression that you were using this in studio. It prints the table’s memory address because that’s how it functions in normal lua. You could do this though:

local function get_varargs_table(...)
   return '{ ' .. table.concat({...}, ', ') .. ' }'
end

Thank you so much everyone! helped me a lot in my learning, thank you! :smiley: