lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 2014-09-26 10:36:32 +0000, Choonster TheMage said:


On 26 September 2014 20:32, Philipp Kraus <philipp.kraus@flashpixx.de> wrote:

Hello,


I have got a Lua function which is filled by the C API.


function myFunction( ... )

        local args = {...}


        -- do something with args


        return args ?

end


The args is a table, but I would like to return the arguments in an equal way in which the args are put to the function. My fuction myFunction should be used in this way:   a,b,c = myFunction( 1, "test", true ) or

a,b = myFunction( 1, 2 )


How can I do this on the return line?


Thanks a lot


Phil

 

If you want to return the original arguments, just use `return ...`. If you modify the args table in some way and want to return that as a series of values, use table.unpack (unpack in 5.1).


Thanks the "unpack" call works well :-)


Phil