摘要: Lua中的table就是一种对象,但是如果直接使用仍然会存在大量的问题,见如下代码:1 Account = {balance = 0}2 function Account.withdraw(v)3 Account.balance = Account.balance - v4 end5 --下面是测试调用函数6 Account.withdraw(100.00) 在上面的withdraw函数内部依赖了全局变量Account,一旦该变量发生改变,将会导致withdraw不再能正常的工作,如:1 a = Account; Account = nil2 a.withdraw(100.00) ... 阅读全文
posted @ 2012-07-06 08:51 OrangeAdmin 阅读(15032) 评论(5) 推荐(7) 编辑