How do I overload += operator?

Jack jckj33 at gmail.com
Mon Jan 25 21:54:03 UTC 2021


On Monday, 25 January 2021 at 17:12:47 UTC, Paul Backus wrote:
> On Monday, 25 January 2021 at 17:09:22 UTC, Jack wrote:
>> I'd like to make this work s += 10 where s is a struct. How 
>> can I do that?
>
> +=, -=, *=, and other compound assignment operators can be 
> overloaded by defining `opOpAssign`:
>
> https://dlang.org/spec/operatoroverloading.html#op-assign

thanks


More information about the Digitalmars-d-learn mailing list