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

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -