« Module:TableBuilder » : différence entre les versions

Contenu supprimé Contenu ajouté
m orthographe
Hlm Z. (discussion | contributions)
Aucun résumé des modifications
Ligne 2 :
 
local meta = {}
 
meta.concat = function(t, ...)
return table.concat(t, ...)
end
meta.insert = function(t, ...)
table.insert(t, ...)
return t
end
 
meta.remove = function(t, ...)
table.remove(t, ...)
return t
end
 
meta.sort = function(t, ...)
table.sort(t, ...)
return t
end
 
meta.maxn = function(t)
return table.maxn(t)
end
 
meta.concat = function(t, ...)
return table.concat(t, ...)
end
 
meta.__index = function(t, key)
local metafunc = meta[key]
if type(metafunc) == 'function' then
return (function (...) return metafunc(t, ...) end)
end
end
 
local TableBuilder = {
new = function()
local t = { }
setmetatable(t, meta)
return t
end
}
 
return TableBuilder