diff --git a/index.html b/index.html
index 1b04d4d..2c9924e 100644
--- a/index.html
+++ b/index.html
@@ -596,8 +596,8 @@ print(a:dist(b)) -- prints 1.4142135623731
For an example, see below. Also be sure to read the
warning regarding metamethods.
@@ -642,15 +642,19 @@ print(Feline) -- prints 'Feline'
-
- function Interface(name)^ top
- Shortcut to
Class{name = name}
, i.e. a possibly named class without constructor.
-
-
function Inherit(class, super, ...)^ top
Add functions of
super
to
class
. Multiple interfaces can be defined.
-
super
's constructor can be accessed via super.construct(self). See example below.
+
super
's constructor can be accessed via super.construct(self). See below.
+
+ function Class:Inherit(super, ...)^ top
+ Syntatic sugar for
Inherit(Class, super, ...)
. Using a lowercase
Class:inherit(super, ...)
is also valid.
+
+
+
+ function Class.construct(object, ...)^ top
+ Calls constructor for
Class
on
object
. This is done to initialize the
+ super-classe's context in a sub-class. See the example below.
@@ -672,7 +676,7 @@ Cat = Class{name = "Cat", function(self, name, size, weight)
Feline.construct(self, size, weight)
self.name = name
end}
-Inherit(Cat, Feline)
+Cat:Inherit(Feline)
function Cat:stats()
return string.format("name: %s, %s", self.name, Feline.stats(self))
@@ -682,16 +686,17 @@ end
Tiger = Class{name = "tiger", function(self, size, weight)
Feline.construct(self, size, weight)
end}
-Inherit(Tiger, Feline)
+Tiger:Inherit(Feline)
function Tiger:speak() print("ROAR!") end
felix = Cat("Felix", .8, 12)
hobbes = Tiger(2.2, 68)
-print(felix:stats(), hobbes:stats())
-felix:speak()
-hobbes:speak()
+print(felix:stats()) -- "name: Felix, size: 0.80, weight 12.00"
+print(hobbes:stats()) -- "size: 2.20, weight 68.00"
+felix:speak() -- "meow"
+hobbes:speak() -- "ROAR!"
@@ -705,7 +710,7 @@ function A:__add(other) return A(self.x + other.x) end
function A:show() print("A:", self.x) end
B = Class(function(self, x, y) A.construct(self, x) self.y = y end)
-Inherit(B, A)
+B:Inherit(A)
function B:show() print("B:", self.x, self.y) end
function B:foo() print("foo") end