getters and setters not an lvalue
maarten van damme
maartenvd1994 at gmail.com
Wed Oct 31 05:46:03 PDT 2012
In my current code I'd like to do something ala:
void main(){
getsettest test=new getsettest();
test.value+=1;
}
class getsettest{
int myvalue;
this(){
}
@property{
int value(){
return myvalue;
}
void value(int value){
myvalue=value;
}
}
}
but this gives the following error:
test.d(4): Error: test.value() is not an lvalue
Is there a rationale behind this decision of not translating
test.value+=1 to test.value= test.value +1 ?
More information about the Digitalmars-d-learn
mailing list