RosettaCodeData/Task/Inheritance-Multiple/Lua/inheritance-multiple.lua
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

13 lines
428 B
Lua

function setmetatables(t,mts) --takes a table and a list of metatables
return setmetatable(t,{__index = function(self, k)
--collisions are resolved in this implementation by simply taking the first one that comes along.
for i, mt in ipairs(mts) do
local member = mt[k]
if member then return member end
end
end})
end
camera = {}
mobilephone = {}
cameraphone = setemetatables({},{camera,mobilephone})