`this` table - tanevnikola/lua-oos GitHub Wiki

It is a reference to the class instance itself. Simple as that, or as this :). Whatever field we define under this table is accessible to all other methods of this class, all methods from the inheritance tree up to this class (super-classes) as well as from outside. Whenever you type this.x = 5; think of it as you have defined a public field x with value 5.

Example

ft.class.Test() {
    getThisFromBase = function()
        return this;
    end;
}
ft.class.Extended(ft.class.Test) {
    getThis = function()
        return this;
    end;
}

local instance = ft.class.Extended();
print(instance == instance.getThis());
print(instance == instance.getThisFromBase());

Output

true
true

as you can see this is actually the instance and is same whether is accessed from the base class, top class or from the outside by referencing the instance of the class.