How do I overload += operator?

Paul Backus snarwin at gmail.com
Mon Jan 25 17:12:47 UTC 2021


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


More information about the Digitalmars-d-learn mailing list