Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Mere = {Val1 = 10}
- function Mere.hello (text)
- print("This is ",text)
- end
- function Mere.increment(self,byV)
- self.Val1 = self.Val1 + byV
- end
- function Mere:new (o)
- o = o or {}
- setmetatable(o, self)
- self.__index = self
- return o
- end
- m1 = Mere:new{Val1 = 100}
- --print(m1.Val1)
- m1:increment(10)
- --print(m1.Val1)
- --print(Mere.Val1)
- Fille = Mere:new() --activate inheritence
- function Fille.HelloFille(self)
- print("fille",self.Val1)
- end
- f = Fille:new() --create instance of subclass
- f:HelloFille() --: call pass object (self) as first param
- f:increment(89)
- print(f.Val1)
- print(Mere.hello("Cool"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement