-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest2.lua
154 lines (124 loc) · 2.55 KB
/
test2.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
local x = {
name = 'simen',
say = nil
}
function _say(x, w)
print(x.name .. ' hi ' .. w)
x.shout = function (xx,x1)
print(xx.name .. 'shout')
end
end
x.say = _say
x:say('yo')
x.shout(x, 'yo')
local h = 1234
local k = 'xxxx' .. h
print(k)
x:shout('yo')
-- local x = { id = 1}
-- function x:x(name)
-- function y()
-- print('hi')
-- self.id = self.id + 1
-- print(self.id)
-- end
-- y()
-- print(name)
-- end
-- x:x('simen')
-- print(x.id)
-- print( tonumber(nil))
-- local x = {
-- fn = function (w, k)
-- print(w)
-- print(k)
-- end,
-- a = { 'hi', 'you' }
-- }
-- local y = { 1, 2}
-- print(unpack(y))
-- function X(...)
-- local a, b, c = ...
-- print(a)
-- print(b)
-- print(c)
-- end
-- -- X(1, 2 )
-- local oid
-- oid = tonumber(oid) or oid
-- print(oid)
-- local x = 120
-- local x = tonumber(x) or x
-- print(x)
-- print(type(x))
-- local Person = {
-- name = 'simen',
-- gender = 'male',
-- }
-- -- setmetatable(Person, {
-- -- __call = function (_, ...)
-- -- return Person:new(...)
-- -- end
-- -- })
-- function Person:new(o, name)
-- o = o or {}
-- self.__index = self
-- print('Person self: ')
-- print(self)
-- o = setmetatable(o, self)
-- o.name = name
-- o.counter = 0
-- o.count = function ()
-- print(o.counter)
-- o.counter = o.counter + 1
-- end
-- return o
-- end
-- -- function Person:init(name)
-- -- self.name = name
-- -- end
-- function Person:greet(callback)
-- --print(self)
-- print('hi, I am ' .. self.name)
-- if (self.mail) then
-- print('mail: ' .. self.mail)
-- end
-- if (callback) then callback('greeted') end
-- end
-- function Person:identify(callback)
-- local c = 'out'
-- print('#######1')
-- print(self)
-- self.greet({ name= 'hi', mail= 'how' }, function ()
-- print('#######2')
-- print(self)
-- print(c)
-- callback()
-- end)
-- end
-- local psn1 = Person:new({}, 'hedy')
-- psn1.count()
-- psn1.count()
-- psn1.count()
-- psn1.count()
-- psn1.count()
-- psn1.count()
-- print(psn1.counter)
-- -- psn1:identify(function ()
-- -- print('#######3')
-- -- print(self)
-- -- end)
-- -- print('Person class: ')
-- -- print(Person)
-- -- print('Person psn1: ')
-- -- print(psn1)
-- -- -- psn1.name = 'hedy'
-- -- psn1.mail = 'abc.com'
-- -- -- psn1.gender = 'female'
-- -- print('**************')
-- -- Person:identify()
-- -- psn1:identify()
-- -- Person:greet()
-- -- psn1:greet()
-- -- -- print(Person.mail)
-- -- -- print(psn1.mail)