S
Size: a a a
S
CP
S
AM
...
tbl = {}
function tbl.foo(a, b)
print("Hello", a + b)
end
function tbl.foo(a, b)
print("World", a - b)
end
tbl.foo(10, 20)
> Hello 30
> World -10
AM
AM
S
AB
S
AM
S
AM
AM
S
AB
ВГ
stor = {}
tbl = setmetatable(
tbl,
{
__newindex = function(self, key, foo)
stor[key] = stor[key] or {}
table.insert(stor[key], foo)
end,
__index = function(self, key)
return function(...)
for _, f in ipairs(stor[key]) do
f(...)
end
end
end
}
)
ВГ
ВГ
S
AB