845.79K
Категория: ПрограммированиеПрограммирование

Lua data types

1.

“Lua data types”
Prepared by: S. S. Kochetkov
ИФИмд-19

2.

OUTLINE
1. Basic Lua data types
2. Using of different types of data
3. Type conversion
2

3.

PURPOSE
• to convey to the audience full information about lua data
types in a convenient form, to study the data types that lua
gives, to learn how to use variables of various types and
convert them to each other.
3

4.

Semicolon
“a camel is a horse developed by a committee”
;
4

5.

The First Point: Basic Lua data types
Type
nil
boolean
number
string
table
function
userdata
thread
5
Example
a = nil
b = true
n=1
s = 'abc'
t = {a, b, c}
foo = function(x) return 2*x end
u = some_C_struct
co = coroutine.create( function () print("hi") end)

6.

The Second Point:
Using of different types of data
Boolean
6

7.

The Second Point:
Using of different types of data
Number
7

8.

The Second Point:
Using of different types of data
String
8

9.

The Second Point:
Using of different types of data
String
9

10.

The Second Point: Using of different types of data
10

11.

The Second Point:
Using of different types of data
Table
11

12.

The Second Point:
Using of different types of data
Table
12

13.

The Second Point:
Using of different types of data
Table
13

14.

15.

The Second Point:
Using of different types of data
Table
15

16.

The Second Point:
Using of different types of data
Function
16

17.

The Second Point:
Using of different types of data
Function
17

18.

The Second Point:
Using of different types of data
Function
18

19.

The Third Point: Type conversion
To boolean
19

20.

The Third Point: Type conversion
To number
20

21.

The Third Point: Type conversion
To string
21

22.

SUMMARY
1. There are eight basic types in
Lua: nil, boolean, number, string, userdata, function, threa
d, and table.
2. Variables have no predefined types - any variable may
contain values of any type
3. Lua has its own type conversion system.
22

23.

CONCLUSION
Remember the features of data types in lua
Consider type conversion mechanisms when writing programs
23

24.

References
Programming in Lua (first edition) (eng) - is a detailed and
authoritative introduction to all aspects of Lua programming
written by Lua's chief architect
tutorialspoint.com (eng) – is online tutorial for self-study
24

25.

Thanks for attention
Contacts
[email protected]
+79779502335
25
English     Русский Правила