开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜