Skip to content

Instantly share code, notes, and snippets.

@u1tnk
Created June 6, 2012 02:13
Show Gist options
  • Select an option

  • Save u1tnk/2879436 to your computer and use it in GitHub Desktop.

Select an option

Save u1tnk/2879436 to your computer and use it in GitHub Desktop.
Parent = {
hoge = 1
}
function Parent:new (o)
o = o or {}
setmetatable(o, self)
self.__index = self
return o
end
function Parent:getHoge()
return rawget(self, "hoge")
end
Child = Parent:new()
print(Child.hoge)
Child.hoge = 23
print(Child.hoge)
print(Child:getHoge())
print(rawget(Child, "hoge"))
function Child:getHoge()
return "hoge"
end
print(Child:getHoge())
print(rawget(Child, "hoge"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment