当前位置:网站首页>Lua Foundation
Lua Foundation
2022-07-24 06:11:00 【It's really all right, duck】
Lua The declared variables are global variables by default , Declare local variables plus local Prefix , such as local a Express a Is a local variable
Variables that have not been declared are nil, Similar to other languages null
Support multiple assignments :a,b=1,2
Lua There is number type : Double precision type ,c in int,float,double All belong to lua Of number type
Lua And support 16 Mechanism representation , It also supports scientific counting , Support the operation of moving left and right
character string
Lua String type (string): Use single or double quotation marks to represent the string , Escape character support
The string connection operation is not a plus sign, but two points , Like strings a, character string b, take a and b The connection is a..b
Number Convert to character type :c=tostring(10)
Convert character type to number:n=tonumber(“10”), If the conversion fails n Namely nil
Get string length : Precede the string with #, such as #c You can get c Length of string
Lua function

You can also write like this

Table:
Table Numeric subscript

Extract the elements inside with subscripts , however lua Subscript from 1 Start
Table Everything in it can be stored
Insert elements :table.insert(a,”d”) stay table a Insert... At the end of d
You can also specify the insertion position :table.insert(a,2,”d”) stay table a Insert in the second position of d
Remove elements :table.insert(a,,2) Remove the second element , Passing will also return the removed element
Table String subscript :

Similar to hash table
Print elements

Additive elements

Global table _G
All global variables are in the global table
stay lua There's only false and nil On behalf of false , Everything else stands for truth , such as 0 It's true, too
Branch judgment statement

use then and end Represents a block of code
Loop statement
For loop :

initial value 1, End value 10, You can also add another parameter : step

Here the step size is 2
Here in the face of i It cannot be changed

When i be equal to 5 To exit the loop
While loop

do end It's a block of code
Out-of-service n-=1
边栏推荐
- day4-jvm
- 用指针访问二维数组
- 【数据库系统原理】第四章 高级数据库模型:统一建模语言UML、对象定义语言ODL
- ue4 瞄准偏移
- Dameng database_ Common user management commands
- day4-jvm
- STM32 DSP library MDK vc5\vc6 compilation error: 256, (const float64_t *) twiddlecoeff64_ 256, armBitRevIndexTableF64_ 256,
- Accessing a one-dimensional array with a pointer
- 力扣:1-两数之和
- CRC-16 MODBUS code
猜你喜欢

day1-jvm+leetcode

Paper reading endmember guided unmixing network (EGU net)
![[MYCAT] MYCAT configuration file](/img/53/63a633d3ae917e3754f9f7f5c6567f.png)
[MYCAT] MYCAT configuration file
![[principles of database system] Chapter 5 algebra and logic query language: package, extension operator, relational logic, relational algebra and datalog](/img/6a/c30b139823208a2e021135a4bf8d58.png)
[principles of database system] Chapter 5 algebra and logic query language: package, extension operator, relational logic, relational algebra and datalog

使用Qt连接MySql并创建表号、写入数据、删除数据

顺序栈 C语言 进栈 出栈 遍历

Openpose2d转换3d姿态识别
![[principles of database system] Chapter 4 advanced database model: Unified Modeling Language UML, object definition language ODL](/img/51/7387c73148ee7bd1034bb6e77af7f0.png)
[principles of database system] Chapter 4 advanced database model: Unified Modeling Language UML, object definition language ODL

day1-jvm+leetcode
![[MYCAT] MYCAT sub database and sub table](/img/a8/ebaedfa084754ef3c96f42ed78eb81.png)
[MYCAT] MYCAT sub database and sub table
随机推荐
Calculation steps of principal component analysis
Conversion of world coordinate system, camera coordinate system and image coordinate system
ue4 换装系统 2.换装系统的场景捕捉
论文阅读-Endmember-Guided Unmixing Network (EGU-Net) 端元指导型高光谱解混网络
Openpose Unity 插件部署教程
day5-jvm
Channel attention and spatial attention module
用指针访问一维数组
Yolov5 learning summary (continuously updated)
力扣:1-两数之和
JUC concurrent programming foundation (9) -- thread pool
day5-jvm
使用Keras实现 基于注意力机制(Attention)的 LSTM 时间序列预测
day1-jvm+leetcode
unity2D游戏之让人物动起来-上
Jupyter notebook select CONDA environment
Statistical analysis of catering data --- Teddy cloud course homework
Synergy LAN realizes multi host shared keyboard and mouse (AMD, arm)
Lunix命令入门 - 用户及文件权限(chmod 详解)
餐饮数据统计分析---泰迪云课程大作业