properties
You are here :

Sub nodes

Recent changes
Site plan
 
 

Properties have two purpose :

Syntax :

 ResultType property ([] | propertyName) (Arguments) [const] {
 }

Example :

 class Test {
   private int myField;
   public sub property myField(const int value) {
     this.myField = value;
   }
   public int property myField() const {
     return myField;
   }
   public int property[] (const word index1, const word index2) const {
     return index1 * index2;
   }
   public sub property[] (const int value, const word index1, const word index2) {
     // do something with value, index1, index2
   }
 }

The two first properties are get and set properties (distinction is based on the constness of the method). The two last properties are array operators indexed by two dimensions.

Writing :

 Test test = new Test();
 int i = test.myField;
 test.myField = 4;
 int j = test[0, 0];
 test[0, 0] = 4;

is equivalent to :

 Test test = new Test();
 int i = test.property myField();
 test.property myField(4);
 int j = test.property[](0, 0);
 test.property[](4, 0, 0);
Propulsed by Wiclear