Statement METHOD (Implementation) Foundation
Prefaces the source code for a method of a class
METHOD [<ClassName>:] <MethodName> [( [<Parameters,...>] )]
When the declaration METHOD is positioned in the source code outside of the class declaration (outside the CLASS...ENDCLASS statements), it introduces the source code for a declared method. Methods are programmed like procedures or user defined functions, but they are called differently. An object of the applicable class must first be created by calling the class method :new(). The method name is then sent to this object using the send operator (the colon). The object executes the source code of the method.
Just like functions or procedures, methods can receive arguments whose values are assigned to the variables declared in the parameter list <Parameters,...>. These variables are LOCAL and are visible only within the source code of the method. A special feature of methods (as opposed to functions) is the LOCAL variable self, which implicitly exists within each method. It always references the object executing the method. Within methods the variable self can neither be explicitly declared nor have a value assigned to it.
Instead of sending a message to the object with self:, the operator :: can be used. The operator :: represents an abbreviation for self: and can be used to access member variables or to call methods of the object.
As with functions and procedures the source code of a method ends with the RETURN statement and the object returns the RETURN value. When a method has no other meaningful RETURN value, self should be returned. In this way, a chained set of messages to an object is possible (for example, object:method1():method2():method3()).
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.