I wanted to know the use of these two and their differences. I have seen that they have a similar use, but what I have seen does not really explain which one is better to use and why.
I wanted to know the use of these two and their differences. I have seen that they have a similar use, but what I have seen does not really explain which one is better to use and why.
self:
It references the current class and you would generally use it when an instance of it is not generated, such as when using static methods:
Este:
Now, with
this
you refer to the current object. This is a class that does have an instance:You should consider that static methods can NOT be referenced using
this
but public, private and protected methods.