Account = { balance = 0, withdraw = function(self, v) self.balance = self.balance - v end } --:操作符隐藏了self或者this参数,操作方便 function Account:deposit(v) self.balance = self.balance + v end --用.操作就需要指定操作的类型 Account.deposit(Account, 200.00) Account:withdraw(100.00)
时间: 2024-10-12 12:35:29