01: hello world
codes:
print("hello lua!") print("你好LUA")
02.
a=1 b="abc" c={} d=print print(type(a)) print(type(b)) print(type(c)) print(type(d))
Result:
number
string
table
function
03. 注释
on_two_3=123 --is valid varable name
--表示注释语句
print(_VERSION) --输出lua的版本
ab=1 Ab=2 AB=3 print(ab,Ab,AB)//1 2 3
04.
AND=3 print(AND) --3
05 . 转义字符
a="single 'quoted' string and double \"quoted\" string inside" b='single \'quoted\' string and double "quoted" string inside' c=[[multiple line with 'single' and "double" quoted strings inside.]] print(a) print(b) print(c)
结果:
>lua -e "io.stdout:setvbuf 'no'" "02.lua"
single 'quoted' string and double "quoted" string inside
single 'quoted' string and double "quoted" string inside
multiple line with 'single' and "double" quoted strings inside.
>Exit code: 0