I very often use self:function system to be able to access the self.
However, sometimes there is no need for : but I could as well use self.function.
As example I have this:
Code: Select all
myfunc.IDwasfound(ID)
if ID > -1
return(true)
else
return(false)
endif
endfunction
Code: Select all
myfunc:funcaboutsomething()
self:FindIDfromTable(nameofitem)
if self.IDwasfound = false then return(FALSE)
do all kinds of stuff...
endfunction
But this can also lead to some trouble.
For if I have some Functions that use ARGs, meaning there can be variable amount of variables, then there is high chance for bugs, since I might declare function correctly as myfunc.function, but when I use it, I might accidentally call it with myfunc:Function, in which case the first ARG is not what I meant it to be, but will be self instead.
Therefore I am wondering should I simply keep using myfunc:fund on all places, even when not needed to avoid these kind of bugs from happening, which can also be hard to find and notice, or should I rather use . when there is no self and : only when self is included?
Any opinions? How do you yourself do?