Lua multiple assignment with tables -


this code:

function foo()     return 1, 2, 3 end  bar = {}  bar = {a, b, c = foo()} 

produces:

bar.a = nil bar.b = nil bar.c = 1 

how can written get:

bar.a = 1 bar.b = 2 bar.c = 3 

without having write this:

function foo()     return 1, 2, 3 end  bar = {} a, b, c = foo()  bar = {a = a, b = b, c = c} 

bar = {} bar.a, bar.b, bar.c = foo() 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -