lua 常用内置函数


lua 常用内置函数

      

                   

                                 

_VERSION 变量

        

查看当前lua的版本号

 A global variable (not a function) that holds a string 
containing the running Lua version. The current value 
of this variable is "Lua 5.4".
# _VERSION是全局变量,不是函数,保存了当前lua的版本号

         

示例

Lua 5.4.4  Copyright (C) 1994-2022 Lua.org, PUC-Rio
-- 当前lua的版本号为5.4
> _VERSION
Lua 5.4

       

            

                                 

type 函数

        

查看数据类型:type(variable_name)

Returns the type of its only argument, coded as a string. 
# 以字符串的形式返回结果

The possible results of this function are 
"nil" (a string, not the value nil), 
"number", "string", "boolean", "table", 
"function", "thread", and "userdata". 
# 可能的结果为:nil(字符串)、number、string、boolean
#             table、function、thread、userdata

                

示例

Lua 5.4.4  Copyright (C) 1994-2022 Lua.org, PUC-Rio
 # nil类型
> type(nil)
nil
 
# number类型
> type(2)
number
 
# string类型
> type("gtlx")
string
 
> type("2")
string
 
# function类型
> function fun() return 1 end
> type(fun)
function
 
# table类型
> t={}
> type(t)
table

         

                 

                                 

print 函数

        

将信息打印到控制台:print(...)


                
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值