Objects are instances of a class.
Classes are objects, so they have methods.
'self class' returns the class of self.
If a class doesn't have a methods ...
... the search continues in the superclass.
(every class has a superclass ... apart from Object).
If you download the Blue Book - "Smalltalk-80 - The language and it's
implementation",
it's free on the net, you'll find an AWSOME explanation and diagram from
page 270 on, until ...
... the final map : classes and metaclass.
but you've to read it these pages, before. There's a 'metaclass' concept
to acquire.
Bon voyage !
Davide
On 12/12/2020 20:20, g_patrickb--- via Pharo-users wrote:
I understand if you have Class A with methods p and q that you can
call q from p doing:
self q
But there are some cases where a method doesn’t exist but self is
still used. I found a tutorial on creating a Reddit type app and it
had a .mcz which I loaded.
Here is an example from Class StLoggedInComponent and method
refreshReport:
self report rows: (self session user tasks select: self filterBlock).
There is a method ‘report’ so I understand that, but there is no
method named ‘session’ so what is the use of self?
And Class StDatabase has method ‘updateTask:’ has:
self subclassResponsibility.
But no method called ‘subclassResponsibility’ exists in the Class.
Also, Class StLoggedInComponents has method ‘testTasks’ with this:
^ self class testTasks
What is ‘self class’?
Thank you.
--
Ing. Davide Grandi
linkedin : http://linkedin.com/in/davidegrandi