LUAFeaturesPrivate PrivacyLearning notes are the content to be introduced in this article.LuaOfPrivate PrivacyFor more information, see the detailed description in this article.
Lua is not intended to be used for large-scale program design. On the contrary, Lua targets small to medium-sized program design, typically as part of a large system.
Typically, it is developed by one or a few programmers, or even used by non-programmers. Therefore, Lua should avoid too much redundancy and human restrictions. If you do not
If you want to access something in an object, do not access If you do not want to access something inside an object, just do not do it .).
- function newAccount (initialBalance)
- local self = {balance = initialBalance}
- local withdraw = function (v)
- selfself.balance = self.balance - v
- end
- local deposit = function (v)
- selfself.balance = self.balance + v
- end
- local getBalance = function () return self.balance end
- return {
- withdrawwithdraw = withdraw,
- depositdeposit = deposit,
- getBalancegetBalance = getBalance
- }
- end
- acc1 = newAccount(100.00)
- acc1.withdraw(40.00)
Summary: DetailsLUAFeaturesPrivate PrivacyThe content of the study notes has been introduced. I hope this article will help you!