The format is:
Access-control setter Setter-name(Argument)
This is a definition that starts with access control, followed by the setter keyword, and ends with the endsetter keyword.
You can define setters with different argument class even if they have a same name. You can place them anywhere in the class definition.
An assignment to setter is automatically converted to a setter call.
Setter definition will generate a scope.
You can specify the access level of the setter using the open or closed keywords.
If specifies open, you can call the setter from outside of the class definition.
If specifies closed, the setter can only use inside of the class definition.
This is a keyword that indicates that it is a setter definition. It must be specified next to access control.
It specifies the setter name after "setter". The naming rules for setter name is the same as for identifiers.
Exceptionally, you can use the name of built-in class as the setter name.
Seeter argument is specified next to the Setter-name, it must be enclosed by parentheses.
An argument is a pair of class name and argument name. One argument is required for the setter. The argument class is the class of the value that can be assigned to the setter.
You can define setters with the same name but different argument class. This is because setters are also distinguished in the argument class.
This is a keyword that indicates the end of the setter definition.
You can use the abbreviation "es" instead of "endsetter". Note that "es" is also a keyword.
Let's define setters in the example class.
open fitter example() // Default fitter.
x = 0;
y = 0;
open fitter example(int xx, int yy) // Fitter with two arguments.
x = xx;
y = yy;
ef // Abbreviation.
open setter X(int val)
x = val;
open setter Y(int val)
y = val;
es // Abbreviation.
The setter is called by an assignment statement.
example ex = new example();
ex.X = 10; // open setter X(int val)
ex.Y = 10; // open setter Y(int val)