- Lua Quick Start Guide
- Gabor Szauer
- 163字
- 2021-08-05 10:30:41
Misc operators
The miscellaneous operators presented here do not fit into any of the previous groups. These operators are Lua constructs.
The assignment operator (=) changes the value of a variable. This operator has been used many times up until this point. The assignment operator allows for multiple assignment. All of the following are valid:
x = 2
y, z = 4, "hello"
The string concatenation operator (..) will combine two strings into a single string. This operator was covered in the String types section of this chapter. As a reminder, the syntax is:
hello = "hello,"
world = " world"
print (hello .. world)
Finally, the length operator (#) is a unary operator that will return the length of a string or a table. The use of this operator for strings has already been covered. The syntax of this operator is as follows:
print ("Enter a word: ")
word = io.read();
print (word .. " has " .. #word .. " letters!")
推薦閱讀
- Progressive Web Apps with React
- Computer Vision for the Web
- Learning Selenium Testing Tools with Python
- INSTANT FreeMarker Starter
- Scala Design Patterns
- HTML5+CSS3基礎開發教程(第2版)
- The DevOps 2.4 Toolkit
- jQuery開發基礎教程
- JavaScript+jQuery網頁特效設計任務驅動教程
- OpenCV 3 Blueprints
- Java 從入門到項目實踐(超值版)
- C語言從入門到精通
- Deep Learning for Natural Language Processing
- 體驗之道:從需求到實踐的用戶體驗實戰
- Koa與Node.js開發實戰