码迷,mamicode.com
首页 > 其他好文 > 详细

体验Lua

时间:2015-04-11 11:42:55      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:

想用之和NGINX结合,终结公司混乱的NGINX配置

玩起来先,感觉很精简,很实用哟。

print("hello world")
a={1,2}
b=a
print(a==b,a~=b)
a=1
b="abc"
c={}
d=print
print(_VERSION)
print(type(a))
print(type(b))
print(type(c))
print(type(d))
a="single ‘quote‘ string and double \"quoteed\"string inside"
c=[[ multiem line
with ‘single‘
and "double" inside.]]
print (c)
a,b,c,d,e = 1, 2, "three", "four", 5, 6
print (a,b,c,d,e )
a, b = b, a
print ("a="..a,"b="..b,c,d,e )
print "hahahaha"
io.write("hehehe")
a={}
b={1, 2, 3}
c={"a", "b", "c"}
print (a, b, c)
address={}
address.Street = "Wyman street"
address.StreetNumber = 360
print(address.StreetNumber)
a = 1
if a == 1 then
    print("a is one")
else
    print("a is not on")
end

a = 1
while a ~= 5 do
    a = a + 1
    io.write(a.." ")
end
a = 0
repeat
    a = a + 1
    print(a)
until a == 5

for a = 1, 4 do io.write(a) end
print()
for a = 1, 6, 3 do io.write(a) end
for xm_key, xm_value in pairs({1, 3, 5, 7}) do print(xm_key, xm_value) end

a = 0
while true do
    a = a + 1
    if a == 10 then
        break
    end
end
print(a)

function myFunc(a, b, c)
    return a, b, c, "hello more", 1, true
end

a, b, c, d, e, f = myFunc(1, 2, "three")
print(a, b, c, d, e, f)

function printf(fmt, ...)
    io.write(string.format(fmt, ...))
end

printf("hello %s from %s on %s\n",
    os.getenv"USER" or "there", _VERSION, os.date())

技术分享

体验Lua

标签:

原文地址:http://www.cnblogs.com/aguncn/p/4417096.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!