post/pre-increment/decrement and property

Robert Clipsham robert at octarineparrot.com
Tue Feb 7 16:50:47 PST 2012


On 07/02/2012 23:04, Timon Gehr wrote:
>> Try this:
>> ----
>> int _foo;
>> @property ref foo() {
>> return _foo;
>> }
>> @property ref foo(int foo) {
>> return _foo = foo;
>> }
>> void main() {
>> ++foo;
>> }
>> ----
>>
>> Using 'ref' instead of auto returns a reference to _foo, allowing it to
>> be modified.
>>
>
> Yes, but then he cannot verify the new value.

So what's actually being asked is can the following happen then?

++foo;

becomes:

foo(foo + 1);

-- 
Robert
http://octarineparrot.com/


More information about the Digitalmars-d-learn mailing list