a="world"
local newtable={}
setmetatable(newtable, {_index=_G})
setfenv(1,newtable)
b="hello"
print(b)
print(a)
................
以上这段代码,为啥会报错呢?错误如下:
lua: noglobal.lua:6: attempt to call global 'print' (a nil value)
a="world"
local newtable={}
setmetatable(newtable, {_index=_G})
setfenv(1,newtable)
b="hello"
print(b)
print(a)
................
以上这段代码,为啥会报错呢?错误如下:
lua: noglobal.lua:6: attempt to call global 'print' (a nil value)