Lua : Storing in a table through a variable name -


i understand why mwe doesn't work don't know how make works. i'd use variable content reference name (not variable name).

salade = {}  name = "tomato"  salade.name = "red"  print (salade.tomato)   -- nil, should red  print (salade.name)     -- red, should nil 

just use normal table indexing syntax, rather tbl.key syntactic sugar:

salade = {} name = "tomato" salade[name] = "red"  print (salade.tomato)   -- red print (salade.name)     -- nil 

Comments