Product Site

5.1.1.17. method

Returns the method object for the receiver class's definition for the method name methodname. If the receiver class defined methodname as unavailable, this method returns .nil. If the receiver class did not define methodname, an error is raised.
Example 5.11. Class class — method method
/* Create and retrieve the method definition of a class */
myclass=.object~subclass("My class")   /* Create a class         */
mymethod=.method~new(" ","Say arg(1)") /* Create a method object */
myclass~define("ECHO",mymethod)        /* Define it in the class */
method_source = myclass~method("ECHO")~source     /* Extract it  */
say method_source                 /* Says "an Array"              */
say method_source[1]              /* Shows the method source code */