Next: Statements
Prev: Tokens
C-- method has the following structure:
disallow_overrides; arg arg1, arg2, ..., [rest]; var var1, var2, ...;Thestatement1 statement2 . . .
disallow_overrides; declaration indicates a non-overridable
method (see Inheritance). Normally, you should omit this
declaration.
The arg declaration gives a list of argument variables, whose
values will correspond to the arguments passed with the message. You
may omit the arg declaration if the method does not take any
arguments. If the final argument variable is given in square brackets
(that is, if you specify rest), then the method can accept a
variable number of argments; rest will contain a list of the
arguments beyond the ones corresponding to the argument variables. If
you do not specify rest, then the method can accept only the
number of arguments specified by the argument variables, no more.
The var declaration tells the compiler that the listed
identifiers should refer to local variables. You may omit the
var declaration if you do not wish to declare any local
variables.
The statements statement1, statement2, ... are the body of the method. They tell the interpreter what the method does.