Yes, that I have understood, but my specific question was about replacing myObj:func with just func?
That is there a way to:
Code: Select all
myfunction(data)
self.data = data
endfunction
myObj:func = myfunction
Notice that the "myfunction" doesnt belong to any class at beginning, that I am only hoping to define that function so that it would later be added as a method on a class through class:func = myfunction
As to explain it alternativale, if i have:
Code: Select all
myfunction(data)
myvar = data
endfunction
myObj:func = myfunction
then this works just fine, as the myfunction is simply changing the myvar to be the value of data.
But what I want to do, is to define this myfunction (which at beginning isnt a method, but normal function) to use "self", so that at later point when it is attached to a class as a method, it would then be using "self".
So idea is that I dont plan to use that myfunction alone at any point. I am just hoping to make it separate so that it is better from code maintenance point of view and then at later point attach it to a class to becoma a method.