arguments - array as parameter list lua -


today working lua,with "oldesh" me language,and did find can arguments array,like soo:

function foo(someting,...)     local arrayofargs = arg     -- code here end 

and now,i'm intresting.can in "other way"? can pass array,not array,but param list,like so:

function bar(a1,a2)     print(a1+a1) end  function foo(someting,...)     local arrayofargs = arg     bar(arg) end 

yes,you cant that.but can somehome make someting that?

if you're talking fact old versions of lua gave automatic arg containing args received vararg function, can local arg={...} right @ beginning of function.

if want convert array list, use table.unpack.

so, example be

function foo(someting,...)     local arg={...}     bar(table.unpack(arg)) end 

but not make sense, since can this, clearer , simpler:

function foo(someting,...)     bar(...) end 

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -