Product Site

5.1.1.8. defineMethods

Incorporates all methods methods in the receiver class's collection of instance methods.

The methods is a collection whose indexes are the names of methods and whose items are method objects (or strings or arrays of strings containing method code). The method names are translated to uppercase. Any existing methods with the same method name in the receiver class are replaced.

If, for any item in methods, the method name is .nil, then a method of this name in the receiver class is made unavailable.

See also method define.

Example 5.3. Class class — defineMethods method
before = .c~new
say before~a                           -- a-original

.c~defineMethods(.methods)
after = .c~new
say after~a after~b                    -- a-define b-define

::method a
return "a-define"
::method b
return "b-define"

::class c
::method a
return "a-original"