- 可包含任何字元,包括 \000,結尾沒有 \000。
- 內容是不能改變的,改變需要另建新字串
- single or double quoted
- escape sequence
- \a:bell
- \b:backspace
- \f:form feed
- \n:換行
- \r:carriage return
- \t:水平跳位
- \v:垂直跳位
- \\:「\」
- \":「"」
- \':「'」
- \數字:最多三位十進位數字,如果後面不是數字,數字開頭的 0 可省略
- double square bracket,類似註解,可用成對的「[[」跟「]]」或「[=[」跟「]=]」(依此類推,兩邊等號數目要相等),不解釋裡面的 escape sequence,例如
page=[[
<html>
<head>
<title>An HTML Page</title>
<head>
<body>
Hello World
</body>
</html>
]]
write(page) - 數字運算時自動轉換成數字,明確轉換用函數 tonumber
- 「..」字串 concatenation operator,如果前面接數字,要有空格,不然會視為小數點。明確轉為字串用函數 tostring
- length operator:字串前面加「#」
- Programming in Lua (second edition) by Roberto Ierusalimschy, Lua.org, March 2006
沒有留言:
張貼留言