跳转到内容

模块:No globals

来自云南百科
云南百科留言 | 贡献2021年10月17日 (日) 08:55的版本 (创建页面,内容为“local mt = getmetatable(_G) or {} function mt.__index (t, k) if k ~= 'arg' then error('尝试读取空全局变量:' .. tostring(k), 2) end return nil end fun…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

此模块的文档可以在Module:No globals/doc创建

local mt = getmetatable(_G) or {}
function mt.__index (t, k)
	if k ~= 'arg' then
		error('尝试读取空全局变量:' .. tostring(k), 2)
	end
	return nil
end
function mt.__newindex(t, k, v)
	if k ~= 'arg' then
		error('尝试写入全局变量:' .. tostring(k), 2)
	end
	rawset(t, k, v)
end
setmetatable(_G, mt)
我们为您提供服务需要使用Cookie。使用我们的服务即表示您同意我们使用Cookie。