Why isn't my dynamic array method doesn't work for this type?

Steven Schveighoffer schveiguy at gmail.com
Fri May 6 13:35:13 UTC 2022


On 5/5/22 4:27 PM, rempas wrote:
> On Thursday, 5 May 2022 at 14:20:49 UTC, Steven Schveighoffer wrote:
>> Your assignment operator does nothing.
>>
> 
> Thanks! That was indeed the problem! In the other data structures, it 
> worked without needing explicitly provide one so I didn't thought about 
> it. Thanks a lot, you're saving me!

You don't need to declare an assign operator, the default for structs is 
to member-wise copy all the values.

However, if you do provide one, it will be used.

Note that a simple default can be done like:

```d
ref My_File opAssign(ref My_File s) return {
     this.tupleof = s.tupleof;
     return this;
}
```

-Steve


More information about the Digitalmars-d-learn mailing list