aboutsummaryrefslogtreecommitdiff
path: root/class_example.lua
blob: ab69b70ad3f3976e020df9aca7e5f9f5a60b3144 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
A = nerv.class()
function A:_init(x)
    self.x = x
end
function A:f()
    return self.x
end

function A:g()
    return self.x + 1
end

B = nerv.class(A)

function B:f()
    return self.x * self.x
end

a = A(3)
b = B(3)
print(a:f())
print(b:f())
print(b:g())