开发者

How can a variable be part of another variables name in lua?

开发者 https://www.devze.com 2023-04-13 00:55 出处:网络
I want to set dynamic vari开发者_运维百科able names. such as function make(name) local name..bar = \"ipsum\"

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

精彩评论

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