- Lua Quick Start Guide
- Gabor Szauer
- 110字
- 2021-08-05 10:30:41
Operator precedence
Much like math, Lua has the concept of operator precedence. In math, 5 + 2 * 10 equals 25 because multiplication happens before addition. Lua behaves the same way; it even uses parentheses to prioritize one group of equations before another. To see this in action, try running the following code snippet:
print ( 5 + 2 * 10 ) -- prints 25
print ( (5 + 2) * 10 ) -- prints 70
Take note of how the output is different; this is because Lua follows mathematical precedence for arithmetic operators. Order of precedence is listed in this table from higher priority (first row) to lower priority (last row):

推薦閱讀
- ClickHouse性能之巔:從架構(gòu)設(shè)計(jì)解讀性能之謎
- Java范例大全
- 零基礎(chǔ)學(xué)C++程序設(shè)計(jì)
- Arduino by Example
- OpenCV for Secret Agents
- Learning Python Design Patterns
- ExtJS Web應(yīng)用程序開(kāi)發(fā)指南第2版
- Appcelerator Titanium:Patterns and Best Practices
- Learning Puppet
- 零基礎(chǔ)入門(mén)學(xué)習(xí)C語(yǔ)言:帶你學(xué)C帶你飛
- jQuery EasyUI從零開(kāi)始學(xué)
- 零基礎(chǔ)學(xué):微信小程序開(kāi)發(fā)
- 區(qū)塊鏈智能合約安全入門(mén)
- 程序員面試筆試寶典
- Elasticsearch技術(shù)解析與實(shí)戰(zhàn)