aboutsummaryrefslogtreecommitdiff
path: root/examples/oop_example.lua
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2015-05-26 12:47:22 +0800
committerDeterminant <[email protected]>2015-05-26 12:47:22 +0800
commit8c5246a8794011ca0c25f15643771f031d258594 (patch)
tree42a4f9d87c99ed35d0c6c1eb768f007387c7d851 /examples/oop_example.lua
parent81c115e09f9449ae61c7352edd77c68e9029f2dc (diff)
correct the oop_example
Diffstat (limited to 'examples/oop_example.lua')
-rw-r--r--examples/oop_example.lua15
1 files changed, 8 insertions, 7 deletions
diff --git a/examples/oop_example.lua b/examples/oop_example.lua
index 712387b..b753288 100644
--- a/examples/oop_example.lua
+++ b/examples/oop_example.lua
@@ -5,11 +5,12 @@ p:set_x(1.0)
p:set_y(2.0)
print(p:norm()) -- get 2-norm of the Point
-p = nerv.BetterPoint(1, 2)
-print(p)
-print(p:norm()) --get 1-norm of the Point
+bp = nerv.BetterPoint(1, 2)
+-- use methods from base class
+bp:set_x(1.0)
+bp:set_y(2.0)
+print(bp)
+print(bp:norm()) --get 1-norm of the Point
--- create a subclass using lua
-local EvenBetterPoint = nerv.class('nerv.EvenBetterPoint', 'nerv.BetterPoint')
-bp = nerv.EvenBetterPoint(1, 2)
-print(p:norm())
+print(p.__typename)
+print(bp.__typename)