lua的全局变量保存在表 _G
中,所以给他上个 metatable
就可以了。
setmetatable(_G, {__index=function(_, k)return k end})
print(hello, world)
__index
是个 metamethod
,当 index
不存在 key
的时候被调用。
lua的全局变量保存在表 _G
中,所以给他上个 metatable
就可以了。
setmetatable(_G, {__index=function(_, k)return k end})
print(hello, world)
__index
是个 metamethod
,当 index
不存在 key
的时候被调用。