lua学习笔记-HelloWorld
2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
運(yùn)行l(wèi)ua腳本,lua hello.lua/dofile("hello.lua")
print("Hello?World?Lua!!!") function?fact(n)if?n?==?0?thenreturn?1else?return?n*fact(n-1)end end print("enter?a?number:") a?=?io.read("*n") print(fact(a))分號(hào)可用可不用。
Lua5.2只支持a-z和A-Z組成的標(biāo)志符。Lua保留下劃線開頭的標(biāo)志符,有特殊用途。
lua保留的關(guān)鍵字:
and????break????do????else????elseif????end????false????goto????for????function
if????in????local????nil????not????or????repeat????return????then????true????until????while
lua is case-sensitive.
lua comment, --[[ 注釋]]--
---[[
? ? print(10)????????-->10
--]]
--[[
????print(10) ? ? ? ?--> no action (commented out)
--]]
全局變量不用聲明,也可以使用,不會(huì)報(bào)錯(cuò)。
print(b) -->nil
b = 10
print(b) -- 10
[[ ?]]表示一個(gè)多文本
a?=?[[ asddsf sdfsdf ]] print?(a)輸出
asddsf
sdfsdf
轉(zhuǎn)載于:https://my.oschina.net/hejunsen/blog/262470
總結(jié)
以上是生活随笔為你收集整理的lua学习笔记-HelloWorld的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java.lang.VerifyErro
- 下一篇: 模式和原则[转载]