Accès aisé aux propriétés

Proposition 1 :
En utilisation le point comme séparateur
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
 
public class Person {
 public property String forename;
 public property int age;
}
Person p = new Person();
p.forename = "Stephen";   // calls setter
String str = p.forename;  // calls getter
Proposition 2 :
En utilisant => comme séparateur

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
 
public class Person {
 public property String forename;
 public property int age;
}
Person p = new Person();
p=>forename = "Stephen";   // calls setter
String str = p=>forename;  // calls getter
Proposition 3 :
En utilisant # comme séparateur

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
 
public class Person {
 public property String forename;
 public property int age;
}
Person p = new Person();
p#forename = "Stephen";   // calls setter
String str = p#forename;  // calls getter