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)
原文:http://www.cnblogs.com/zzyoucan/p/4324930.html