In smalltalk exists the "workspace" environment. BY definition,"self" points to the object inside which the current method is executing. But how am I to understand "current method" when I type code snippets inside the workspace window? There is no current object running any method or I missed something.Anyone can help?
You can debug the code you execute and you will see that you end up executing a temporary method on an object. For instance in Pharo the workspace DoIts create a method on UndefinedObject (nil). So here self will refer to nil.
Try this experiment: type 'self' into a workspace, select it, and select "print it" from the context menu. This will show you what object self is bound to.
In most Smalltalks, self will be nil.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With