How can a variable be part of another variables name in lua?
I want to set dynamic vari开发者_运维百科able names.
such as
function make(name)
local name..bar = "ipsum"
end
make(foo)
this possible?
For globals it's simply indexing like _G[name..bar]
. For locals you could emulate this by setting all globals you use in a local table, and index that one. For an approach to really use a local, I can't help you.
精彩评论