lua 基础知识-命令行方式

命令行方式
lua [options] [script [args]]

-e:直接将命令传入 Lua
prompt> lua -e "print(math.sin(12))" --> -0.53657291800043
-l:加载一个文件.
-i:进入交互模式.
_PROMPT 内置变量做为交互模式的提示符
prompt> lua -i -e "_PROMPT=' lua> '"
lua>函数

 

函数 type 能够测试给定变量或者值的类型

type.lua测试

print(type(a)) --> nil ('a' is not initialized)
a = 10
print(type(a)) --> number
a = "a string!!"
print(type(a)) --> string
a = print -- yes, this is valid!
a(type(a)) --> function

执行lua:this

 

直接使用-e将命令传入lua

type中字符串使用双引号lua

 

type中字符串使用单引号spa

其中lua版本:命令行

 

注释:code

在-e将命令传入lua时,type函数中,单引号和双引号的结果不同ip

相关文章
相关标签/搜索