当前位置:网站首页>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
边栏推荐
- day2-WebSocket+排序
- [MYCAT] MYCAT sets up read-write separation
- Raspberry pie is of great use. Use the campus network to build a campus local website
- STM32 standard peripheral Library (Standard Library) official website download method, with 2021 latest standard firmware library download link
- Unity(二) 更多API和物理引擎
- Accessing a two-dimensional array with a pointer
- Jupyter notebook select CONDA environment
- [raspberry pie 4B] VII. Summary of remote login methods for raspberry pie xshell, putty, vncserver, xrdp
- JDBC进阶—— 师承尚硅谷(DAO)
- 机器学习&深度学习 入门资料分享总结
猜你喜欢
![[MYCAT] MYCAT sub database and sub table](/img/a8/ebaedfa084754ef3c96f42ed78eb81.png)
[MYCAT] MYCAT sub database and sub table

MySQL基础---约束

论文阅读-Endmember-Guided Unmixing Network (EGU-Net) 端元指导型高光谱解混网络

JDBC初级学习 ------(师承尚硅谷)

Foundation of JUC concurrent programming (8) -- read write lock

餐饮数据统计分析---泰迪云课程大作业

Thymeleaf quick start learning

HoloLens 2 中文开发文档 MRTK v2

day6-jvm

How to download videos on the web
随机推荐
JVM系统学习
C语言链表(创建、遍历、释放、查找、删除、插入一个节点、排序,逆序)
data normalization
Foundation of JUC concurrent programming (8) -- read write lock
Unity Shader从内置渲染管线迁移到URP
JUC并发编程基础(9)--线程池
通道注意力与空间注意力模块
Common features of ES6
Jestson installs IBus input method
Foundation of JUC concurrent programming (4) -- thread group and thread priority
MySQL download and installation environment settings
Installation of tensorflow and pytorch frames and CUDA pit records
Sequential stack C language stack entry and exit traversal
什么是单调队列
Openpose2d转换3d姿态识别
使用Keras实现 基于注意力机制(Attention)的 LSTM 时间序列预测
[FatFs] migrate FatFs manually and transfer SRAM virtual USB flash disk
Dameng database_ Common initialization parameters
Day2 websocket+ sort
day1-jvm+leetcode