摘要:
--lua仿单继承Account = { balance = 0}function Account:new(o) o = o or {} setmetatable(o, self)--Account表本身作为o的metatable self.__index = self--自己作为自己的原型 ... 阅读全文
摘要:
Account = { balance = 0}function Account:deposit(v) self.balance = self.balance + vendfunction Account:new(o) o = o or {} setmetatable(o, self)--A... 阅读全文
摘要:
Account ={ balance = 0, withdraw = function(self, v) self.balance = self.balance - v end}--:操作符隐藏了self或者this参数,操作方便function Account:deposit(v) ... 阅读全文