diff options
author | Determinant <[email protected]> | 2015-05-22 15:07:10 +0800 |
---|---|---|
committer | Determinant <[email protected]> | 2015-05-22 15:07:10 +0800 |
commit | 0e250c43b62b7593edc163d0510d229010361707 (patch) | |
tree | c77e5a93d4e287189213fcfcbf0b69b0cfd8fe0f /class_example.lua | |
parent | 54bdb1ca7aae43a8a216ba5824b996b0b442e716 (diff) |
add pl implementation for Lua class
Diffstat (limited to 'class_example.lua')
-rw-r--r-- | class_example.lua | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/class_example.lua b/class_example.lua new file mode 100644 index 0000000..ab69b70 --- /dev/null +++ b/class_example.lua @@ -0,0 +1,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()) + |