Explanation of LUA's proprietary Privacy Study Notes

Source: Internet
Author: User

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 .).

 
 
  1. function newAccount (initialBalance)  
  2.     local self = {balance = initialBalance}  
  3.     local withdraw = function (v)  
  4.        selfself.balance = self.balance - v  
  5.     end  
  6.     local deposit = function (v)  
  7.        selfself.balance = self.balance + v  
  8.     end  
  9.     local getBalance = function () return self.balance end  
  10.    return {  
  11.        withdrawwithdraw = withdraw,  
  12.        depositdeposit = deposit,  
  13.        getBalancegetBalance = getBalance  
  14.     }  
  15. end  
  16. acc1 = newAccount(100.00)  
  17. acc1.withdraw(40.00) 

Summary: DetailsLUAFeaturesPrivate PrivacyThe content of the study notes has been introduced. I hope this article will help you!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.