Product Site

5.1.4.12. instanceMethods

Returns a Supplier object for all the object methods of the receiving object and its superclasses, if no argument is specified. In this case, the supplier's indexes may contain duplicate entries, if classes override methods in superclasses.

If a class_object is specified, instanceMethods returns a Supplier object for only the object methods of the receiving object. If the receiving object object is not an instance of class_object, an empty Supplier is returned.

The returned supplier's indexes are the method names and the supplier's items are their associated Method objects. The Supplier enumerates all the names and methods existing at the time of the supplier's creation.

Note

Methods that have been hidden with a setMethod or define method are included with the other methods that instanceMethods returns. The hidden methods have .nil for their associated method.
Example 5.31. Object class — instanceMethods method
-- if running under ooRexx 5.1.0
-- list all class methods of .String only
say .String~instanceMethods(.String)~allIndexes~sort~toString(,', ')
    -- outputs:  ALNUM, ALPHA, BLANK, CNTRL, CR, DIGIT, GRAPH, LOWER, NEW, NL, NULL,
    --           PRINT, PUNCT, SPACE, TAB, UPPER, XDIGIT

-- count all class methods of .String and its superclasses
say .String~instanceMethods~allIndexes~items
    -- outputs: 83
    --             (17 .String class methods, 33 .Object class methods,
    --              33 .Class class methods, i.e., without its NEW method)

-- count all instance methods of .String only
say ''~instanceMethods(.String)~allIndexes~items
    -- outputs: 117

-- count all instance methods of .String and its superclasses
say ''~instanceMethods~allIndexes~items
    -- outputs: 150
    --             (117 .String instance methods, 32 .Object instance methods,
    --              1 .Comparable instance method)