1. Keyword
And |
Break |
Do |
Else |
Elseif |
|
End |
False |
For |
Function |
If |
|
In |
Local |
Nil |
Not |
Or |
|
Repeat |
Return |
Then |
True |
Until |
While |
2. Data Type
How can we determine the type of a variable? You can use the type () function to check. Lua supports the following types:
Nil |
Null Value. All unused variables are nil. Nil is both a value and a type. |
Boolean |
Boolean value. There are only two valid values: true and false. |
Number |
Numeric value. In Lua, the value is equivalent to double in C. |
String |
String. If you want to, the string can contain the "\ 0" character (which is different from the C language that always ends with "\ 0) |
Table |
Link Table type. This type is powerful. For more information, see the following section. |
Function |
Function type. Do not doubt that a function is also a type. That is to say, all functions are a variable. |
Userdata |
Well, this type is used to deal with Lua's host. Generally, the host is written in C and C ++. In this case, userdata can be any data type of the host, usually including struct and pointer. |
Thread |
Thread type. There is no real thread in Lua. In Lua, a function can be divided into several parts for running. If you are interested, you can go to Lua's documents. Now let's look back at it. I don't think it's a thread type. Instead, the iterator function is used for traversal. For example: Function range (N) Local I = 0 While (I <n) Do Coroutine. Yield (I) I = I + 1 End End Unfortunately, you need the coroutine. Resume function to continue running. Please advise. |