[Newbies] Class of method

Levente Uzonyi leves at elte.hu
Wed Jan 4 20:20:30 UTC 2012

On Wed, 4 Jan 2012, Garret Raziel wrote:

> Hi,
> I have read that method of object is object itself. So my question is, how
> can I send message to that object? Is there for example possibilty to send
> message to the method to decompile itself and show its code? What is method
> subclass of?

Copy this snippet to a Workspace and you'll find the answer to all of your 

"Evaluate the following two lines."
theObject := 42. "Just an object, could be anything."
method := theObject class lookupSelector: #factorial. "Since we know that the object is an integer, and we know that integers understand a message named factorial, therefore we can fetch the method for that name."
"Then print the following lines one by one."
method getSource. "Print this to get the exact source code."
method decompileString. "Print this to get the decompiled source code."
method class. "Print this to get the class of the method"


> Jan

More information about the Beginners mailing list