How do I make a dynamic variable name in Lua?

前端 未结 3 1213
走了就别回头了
走了就别回头了 2020-12-11 18:14

I am new to Lua and am having some difficulties:

I am trying to create dynamic variable names:

local tblAlphabet = {\"a\",\"b\",\"c\",\"d\",\"e\",\"f         


        
3条回答
  •  温柔的废话
    2020-12-11 18:59

    it's not clear what you want to do; but if you want to programmatically create lots of global variables, just remember that globals are fields of the _G table:

    _G['anyvar'] = 'something'
    print (anyvar)
    

提交回复
热议问题