Mòdul:No globals: diferència entre les revisions
Aparença
Contingut suprimit Contingut afegit
m Ha protegit «Mòdul:No globals» : Plantilla sensible o molt usada ([Modifica=Permetre només usuaris autoconfirmats] (indefinit) [Reanomena=Permetre només usuaris autoconfirmats] (indefinit)) |
updated by hand from mw |
||
Línia 2: | Línia 2: | ||
function mt.__index (t, k) |
function mt.__index (t, k) |
||
if k ~= 'arg' then |
if k ~= 'arg' then |
||
-- perf optimization here and below: do not load Module:TNT unless there is an error |
|||
error('En tractar de llegir nil global ' .. tostring(k), 2) |
|||
error(require('Module:TNT').format('I18n/No globals', 'err-read', tostring(k)), 2) |
|||
end |
end |
||
return nil |
return nil |
||
Línia 8: | Línia 9: | ||
function mt.__newindex(t, k, v) |
function mt.__newindex(t, k, v) |
||
if k ~= 'arg' then |
if k ~= 'arg' then |
||
error( |
error(require('Module:TNT').format('I18n/No globals', 'err-write', tostring(k)), 2) |
||
end |
end |
||
rawset(t, k, v) |
rawset(t, k, v) |
Revisió del 20:38, 10 maig 2019
![Icona de documentació de mòdul](http://upload.wikimedia.org/wikipedia/commons/thumb/1/19/Test_Template_Info-Icon.svg/50px-Test_Template_Info-Icon.svg.png)
A continuació es mostra la documentació transclosa de la subpàgina /ús. [salta a la caixa de codi]
![]() | No feu cap canvi. Aquesta pàgina la manté un robot. Qualssevol modificacions han de fer-se a mediawiki.org. Ajudeu a traduir aquesta pàgina. |
![]() | Mòdul obsolet, ara integrat en una llibreria de Scribunto. Useu en el seu lloc: require('strict') |
Aquest mòdul es pot incloure al principi del vostre codi. Informa d'un error quan el codi intenta llegir o escriure una variable no declarada com a local.
local mt = getmetatable(_G) or {}
function mt.__index (t, k)
if k ~= 'arg' then
-- perf optimization here and below: do not load Module:TNT unless there is an error
error(require('Module:TNT').format('I18n/No globals', 'err-read', tostring(k)), 2)
end
return nil
end
function mt.__newindex(t, k, v)
if k ~= 'arg' then
error(require('Module:TNT').format('I18n/No globals', 'err-write', tostring(k)), 2)
end
rawset(t, k, v)
end
setmetatable(_G, mt)