Home News DOC Class DL Others Cooker
Documents  >  Reference  >  Method definition
Method definition

Method definition

A method is a subroutine.

Method definition is the following format.

access-control method return-type method-name(arguments)



It can use the abbreviation em instead of endmethod.

In the class definition, it is possible to define methods of any number at any place outside the other member definitions.

access control

Access-control determines the access level of the method by specifying a keyword either open or closed.

If the access-control is open, you can invoke the method from outside the class definition. If the access-control is closed, you can invoke the method only inside the class definition.

method keyword

method keyword indicates that this definition is method. It must be present between the access-control and return-type.

return type

The return-type is a specification of a type of instance which is returned by method.

You must specify a void if the method does not return a value.

method name

Identifier and embedded class name can use for the method name.


The arguments are pairs of the class name and identifier which is surrounded by parentheses. the pair can be specified any number. When there are two or more the pair, it have to separate by comma.

For example,

open method void sampleMethod()

open method void sampleMethod(int index)

open method void sampleMethod(int index, string message)

There is not a special keyword which indicates that there is no arguments. If the argument is not, you do not have to specify anything in the parentheses

endmethod keyword

An endmethod is a keyword which indicates an end of a method definition. It has to exist at the end of a definition.

It can use the abbreviation em instead of endmethod.


You can define methods of any number which has same name if type and number of arguments are different.


A method generates a scope.

Please refer to the manual about the scope.


A method can return to invoker from anywhere by return statement. The return statement of the method should return an instance of the type which is specified

Copyright © Rice All rights reserved.