Setter definition
Setter definition
Setter is a subroutine which is invoked with the assignment statement format.
Format is:
access-control setter setter-name(argument)
statements
endsetter
You can use the abbreviation es instead of endsetter.
In the class definition, it is possible to define setters of any number at any place outside the other member definitions.
Setter's main aim is the provision of way of access to a field.
access control
Access-control determines the access level of the setter by specifying a keyword either open or closed.
If it is open, you can invoke the setter from outside the class definition. If it is closed, you can invoke the setter only inside the class definition.
setter
The setter is a keyword which indicates this is a setter. It must be present between the access-control and setter-name.
setter name
Identifier and embedded class name can use for the setter name.
argument
The argument is a pair of the class name and identifier which is surrounded by parentheses.
statemants
Statements are optional. Namely, a setter without statements is permitted.
endsetter
The endsetter is a keyword which indicates end of definition. You can use the abbreviation es instead of endsetter.
overload
You can define setters which has same name if class of argument is different.
scope
A setter generates a scope.
return
A setter can return to invoker from anywhere by return statement. The return statement of the setter should not return an instance. If the control has reached the endsetter without encountering a return statement, it returns to invoker.