## digitalmars.D - Signature of opAddAssign

• Andrew Fedoniouk (10/10) Mar 02 2005 what is the proper way from D point of view?
• zwang (2/17) Mar 03 2005 IMO, I prefer the former which enables chained += operations.
"Andrew Fedoniouk" <news terrainformatica.com> writes:
```what is the proper way from D point of view?

struct point
{
point opAddAssign(int i) {  x += i; y += i; return make(x,y);  }
// --or just --
void  opAddAssign(int i) {  x += i; y += i; }
}

( I am porting this into D
http://www.terrainformatica.com/org/gool/geometry.h )

Andrew.
```
Mar 02 2005
zwang <nehzgnaw gmail.com> writes:
```Andrew Fedoniouk wrote:
what is the proper way from D point of view?

struct point
{
point opAddAssign(int i) {  x += i; y += i; return make(x,y);  }
// --or just --
void  opAddAssign(int i) {  x += i; y += i; }
}

( I am porting this into D
http://www.terrainformatica.com/org/gool/geometry.h )

Andrew.

IMO, I prefer the former which enables chained += operations.
```
Mar 03 2005
"Andrew Fedoniouk" <news terrainformatica.com> writes:
``` struct point
{
point opAddAssign(int i) {  x += i; y += i; return make(x,y);  }
// --or just --
void  opAddAssign(int i) {  x += i; y += i; }
}

IMO, I prefer the former which enables chained += operations.

Seems like my question was not clear enough....

what code it produces on a += b ?

Compiler may suppres returning value of opAddAssign
and make value by its own. And that is the question.

As far as I understand there are no 'this' in struct methods (why?)
so I cannot effectively return something like *this from methods.
Am I right?

Andrew.
```
Mar 03 2005
"Andrew Fedoniouk" <news terrainformatica.com> writes:
```Disregard my previous post.
this in struct's works. Just tested it.
Perfect.

"Andrew Fedoniouk" <news terrainformatica.com> wrote in message
news:d07d6n\$1st\$1 digitaldaemon.com...
struct point
{
point opAddAssign(int i) {  x += i; y += i; return make(x,y);  }
// --or just --
void  opAddAssign(int i) {  x += i; y += i; }
}

IMO, I prefer the former which enables chained += operations.

Seems like my question was not clear enough....

what code it produces on a += b ?

Compiler may suppres returning value of opAddAssign
and make value by its own. And that is the question.

As far as I understand there are no 'this' in struct methods (why?)
so I cannot effectively return something like *this from methods.
Am I right?

Andrew.

```
Mar 03 2005