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

rempas rempas at tutanota.com
Fri May 6 17:06:06 UTC 2022


On Friday, 6 May 2022 at 13:35:13 UTC, Steven Schveighoffer wrote:
> 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

Hah! For some reason, I had the idea that it doesn't work 
(meaning it won't compile) without providing an assignment 
operator and that I had test it. I now tested it again and it is 
indeed as you say. Thank you!


More information about the Digitalmars-d-learn mailing list