Lua learning notes --- annotations, variables, strings, and lua learning notes
1. Notes
Single line comment "--" equivalent "//"
Multi-line comment "-- []" is equivalent /**/
Escape nested comments -- [= [] =]
The number of = is not limited, but the number must be equal.
2. Variables
Keyword retention
If
Else
Elseif
Then
End
For
Break
Do
Nil (null)
Local
Function
While
In
And
Or
False
True
Until
Lua variables include global variables and local variables.
All its global variables are stored in a common table,
The advantage of this organizational structure is that, first, there is no need to create a new data structure for global variables, which simplifies the internal implementation of Lua. Another advantage is that, you can operate on this table like other tables. To facilitate this operation, Lua saves the environment table itself in a global variable _ G.
The local declaration is used before the local variable.
Print can be used to display variables, numbers, and strings to terminals.
1> the string format can be single quotation mark ''or double quotation mark" ".
2> escape characters with Backslash "\"
Sometimes a string contains many single or double quotation marks. When using string double quotation marks, use escape characters. If the string content contains many single or double quotation marks, this is very troublesome.
For example, message = "James said," hello ", Li Hong raised his head and said" hello "";
In this case, the [[String] form is used to enclose such strings.
If you are not bothered, you can also use the Escape Character "\"
3> Number