lua学习笔记-HelloWorld
生活随笔
收集整理的這篇文章主要介紹了
lua学习笔记-HelloWorld
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2019獨角獸企業重金招聘Python工程師標準>>>
運行lua腳本,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))分號可用可不用。
Lua5.2只支持a-z和A-Z組成的標志符。Lua保留下劃線開頭的標志符,有特殊用途。
lua保留的關鍵字:
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)
--]]
全局變量不用聲明,也可以使用,不會報錯。
print(b) -->nil
b = 10
print(b) -- 10
[[ ?]]表示一個多文本
a?=?[[ asddsf sdfsdf ]] print?(a)輸出
asddsf
sdfsdf
轉載于:https://my.oschina.net/hejunsen/blog/262470
總結
以上是生活随笔為你收集整理的lua学习笔记-HelloWorld的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java.lang.VerifyErro
- 下一篇: 模式和原则[转载]