官术网_书友最值得收藏!

  • 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):

主站蜘蛛池模板: 莒南县| 玉林市| 芒康县| 绩溪县| 钟山县| 宁明县| 阳春市| 蒙阴县| 海淀区| 金堂县| 鄱阳县| 宁城县| 广河县| 盐亭县| 天气| 桃园市| 鸡东县| 盈江县| 兴和县| 隆安县| 新余市| 新和县| 桐乡市| 田东县| 武胜县| 阿拉尔市| 南漳县| 普兰县| 隆林| 关岭| 定州市| 上饶县| 虞城县| 汝州市| 京山县| 垦利县| 漯河市| 文昌市| 阳西县| 尉氏县| 陆丰市|