Module:Arguments: Difference between revisions
Jump to navigation
Jump to search
m>Mr. Stradivarius m Changed protection level of Module:Arguments: High-risk Lua module ([Edit=Allow only template editors and admins] (indefinite) [Move=Allow only template editors and admins] (indefinite)) |
m>Anomie Fix __pairs and __ipairs functions to handle the nil marker |
||
Line 169: | Line 169: | ||
metatable.doneIpairs = true | metatable.doneIpairs = true | ||
end | end | ||
return | return function ( t, k ) | ||
local nk, val = next( metaArgs, k ) | |||
if val == nilArg then | |||
val = nil | |||
end | |||
return nk, val | |||
end | |||
end | end | ||
Line 177: | Line 183: | ||
metatable.doneIpairs = true | metatable.doneIpairs = true | ||
end | end | ||
return | return function ( t, i ) | ||
local val = metaArgs[i + 1] | |||
if val == nil then | |||
return nil | |||
elseif val == nilArg then | |||
val = nil | |||
end | |||
return i + 1, val | |||
end, nil, 0 | |||
end | end | ||