How to make Function with : on a fly?
Posted: Tue Dec 01, 2020 10:54 am
I have this situation here (writing this longer than necessary to get the idea better)
By other words I am first making a prototype OOP, and then there will come different types of OOPs that are going to be using that Prototype to get their stuff in place, but these different types will have a different "FuncToBeMadeLater" method, that I am planning on making at point I am making New Instance of Type1, Type2, Type3...
But now the problem is that I want to use the SELF system, which means I need to use : when declaring that. However, when I do that at O:FuncToBeMadeLater = Function() stuff EndFunction, it gives me an error.
If I use O.FunctoBeMadeLater instead, it works fine, except I dont have the self then.
Is there a way for me to do this in such a way that I can get the SELF there?
Code: Select all
OOP = {}
Function OOP:NewInstance()
o = {}
o.variable = 1
Return(o)
EndFunction
Function OOP:FuncToBeMadeLater()
EndFunction
Function OOP:NewInstance_Type1()
o = OOP:NewInstance()
o:FuncToBeMadeLater = Function() stuff EndFunction
Return(o)
EndFunction
testOOP = OOP:NewInstance_Type1()
But now the problem is that I want to use the SELF system, which means I need to use : when declaring that. However, when I do that at O:FuncToBeMadeLater = Function() stuff EndFunction, it gives me an error.
If I use O.FunctoBeMadeLater instead, it works fine, except I dont have the self then.
Is there a way for me to do this in such a way that I can get the SELF there?