Skip to main content

Calling Methods of an Instance

Calling Methods of an Instance

To call a method of an instance, you can do any of the following:

  • Create an instance of the associated class, and use dot syntax to call the method of that instance, as described previously.

  • (Within an instance method) to call another instance method of that class (which could be an inherited method), use the following expression:

    ..MethodName(args)
    

    You can use this expression with the DO command. If the method returns a value, you can use SET, or you can use it as part of another expression. The following shows some variations:

     do ..MethodName()
     set value=..MethodName(args)
    
  • To execute an instance method, where the method name is not determined until runtime, use the $METHOD function:

    $METHOD(oref, methodname, Arg1, Arg2, Arg3, ... )
    

    where oref is an OREF, methodname evaluates to the name of an instance method in the associated class, and Arg1, Arg2, Arg3, and so on are any arguments to that method.

    For more information, see $METHOD.

  • (Within an instance method) use the variable $this.

FeedbackOpens in a new tab