언어/lua

4. 자료형

조규현15 2015. 12. 1. 09:03
반응형
Value TypeDescription
nilUsed to differentiate the value from having some data or no(nil) data.
booleanIncludes true and false as values. Generally used for condition checking.
numberRepresents real(double precision floating point) numbers.
stringRepresents array of characters.
functionRepresents a method that is written in C or Lua.
userdataRepresents arbitary C data.
threadRepresents independent threads of execution and it is used to implement coroutines.
tableRepresent ordinary arrays, symbol tables, sets, records, graphs, trees, etc, and implements associative arrays. It can hold any value (except nil).

예제

print(type("What is my type"))   --> stringt=10print(type(5.8*t))               --> numberprint(type(true))                --> booleanprint(type(print))               --> functionprint(type(type))                --> functionprint(type(nil))                 --> nilprint(type(type(ABC)))           --> string

When you build and execute the above program it produces following result on Linux:

stringnumberfunctionfunctionbooleannilstring
출처 : http://www.tutorialspoint.com/lua/lua_data_types.htm


반응형

'언어 > lua' 카테고리의 다른 글

6. 중간 정리  (0) 2015.12.01
5. 연산자  (0) 2015.12.01
3. 함수  (0) 2015.12.01
2. 개발환경 세팅  (0) 2015.12.01
1. Lua 설치 및 설정  (0) 2015.12.01