why properties don't support +=, -= ... operators?

Andrey via Digitalmars-d digitalmars-d at puremagic.com
Tue May 23 10:26:32 PDT 2017


On Tuesday, 23 May 2017 at 16:43:33 UTC, Stanislav Blinov wrote:
> struct Foo
> {
>     private int value_;
>
>     void value(int v) { value_ = v; }
>     ref inout(int) value() inout { return value_; }
> }
>
> void main()
> {
>     import std.stdio;
>     Foo foo;
>     foo.value += 150;
>     writeln(foo.value);
> }
>
> Which inconsistency do you mean? Not calling a function when 
> applying an operator to a property?

yes function not calling when applying an operator.



More information about the Digitalmars-d mailing list