Skip to content

Instantly share code, notes, and snippets.

@litefeel
Created January 26, 2016 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save litefeel/f0cd9c6af4147dfb171f to your computer and use it in GitHub Desktop.
Save litefeel/f0cd9c6af4147dfb171f to your computer and use it in GitHub Desktop.
local a = {}
local Plus = {}
local Base = {}
-- t not self
Plus.__index = function (t, k)
-- output Plus true false false
print("Plus", t == a, t == Plus, t == Base)
return Plus[k]
end
-- t not self
Base.__index = function(t, k)
-- output Base false true false
print("Base", t == a, t == Plus, t == Base)
end
setmetatable(Plus, Base)
setmetatable(a, Plus)
print(a.b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment