lua-Operators(运算符)
Arthmetic Operators
Similiar to other programing languages, there are also + - * / % in Lua. On top of that, lua also has ^ (exponent) operator.
1 | |
Relational Operators
This section is the same to other programing language.
Note: unequal operator is
~=
Logical Operators
This section has a great distinction from others.
NOTE:
Only
nilorfalsewill be recognized as false.
and
Similiar to other language &&

or
Similiar to other language ||

not
Similiar to other language !
Misc Operators
-
..concatenationConcatenates two strings.
1
2
3local a, b = "hello", 'lua'
local c = a .. "-" .. b
print(c) -- hello-lua -
#lengthAn unary operator that return the length of the a string or a table.
1
2
3
4
5
6
7local a = "hello"
local b = #a
print(b) -- 5
local t = {"hello","lua","python"}
local c = #t
print(c) -- 3
lua-Operators(运算符)
https://jackiedai.github.io/2024/01/03/004lua/lua-Operators-运算符/