- 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!")
推薦閱讀
- C++ Primer習題集(第5版)
- Web應用系統開發實踐(C#)
- Python 3.7網絡爬蟲快速入門
- 零基礎搭建量化投資系統:以Python為工具
- Learning Real-time Processing with Spark Streaming
- Learn Programming in Python with Cody Jackson
- Full-Stack Vue.js 2 and Laravel 5
- Effective Python Penetration Testing
- 青少年Python編程入門
- Python算法從菜鳥到達人
- ANSYS Fluent 二次開發指南
- Create React App 2 Quick Start Guide
- Scala Reactive Programming
- 計算機應用技能實訓教程
- Visual C++ 開發從入門到精通