切換選單
切換偏好設定選單
切換個人選單
尚未登入
若您做出任何編輯,會公開您的 IP 位址。

「模組:No globals」:修訂間差異

出自華麥百科
Chunghwamc留言 | 貢獻
建立內容為「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)」的新頁面
 
(無差異)

於 2024年3月23日 (六) 22:44 的最新修訂

可在模組: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)