詳解LUA特性之私人性Privacy學習筆記

來源:互聯網
上載者:User

LUA特性之私人性Privacy學習筆記是本文要介紹的內容,主要是來學習lua私人性Privacy,不多說,具體內容來看本文詳解。

Lua沒有打算被用來進行大型的程式設計,相反,Lua目標定於小型到中型的程式設計,通常是作為大型系統的一部分。

典型的,被一個或者很少幾個程式員開發,甚至被非程式員使用。所以,Lua避免太冗餘和太多的人為限制。如果你不

想訪問一個對象內的一些東西就不要訪問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) 

小結:詳解LUA特性之私人性Privacy學習筆記的內容介紹完了,希望通過本文的學習能對你有所協助!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.