시작

Hello World 출력

print("Hello World")

루아 파일 및 인터프리터 실행

$lua hello.lua
 
$lua
Lua 5.4.2  Copyright (C) 1994-2020 Lua.org, PUC-Rio
>

키워드

andbreakdoelseelseif
endfalseforfunctiongoto
ifinlocalnilnot
orrepeatreturnthentrue
untilwhile

주석

-- single comment
--[[
multi-line comment
--]]

타입과 값

$lua
Lua 5.4.2  Copyright (C) 1994-2020 Lua.org, PUC-Rio
> type(nil)
nil
> type(true)
boolean
> type(10)
number
> type("Hello World")
string
> type(io.stdin)
userdata
> type(print)
function
> type({})
table
> type(type(X))
string

Nil

다른 언어의 None, Null과 비슷한 역활을 한다. 전역변수는 디폴트로 nil 값이 할당된다.

불리언

루아에서는 오직 falsenil만이 거짓으로 평가된다. 0은 아니다.


참고