how to append (ref) int[] to int[][]?

mw mingwu at gmail.com
Mon Jun 8 06:52:36 UTC 2020


On Monday, 8 June 2020 at 06:42:44 UTC, Simen Kjærås wrote:
>
> Arrays (technically, slices) in D are essentially this struct:
>
> struct Array(T) {
>     T* ptr;
>     size_t length;
>     // operator overloads
> }
>
> So when you have int[][], each element of the outer array is an 
> Array!int. These, as simple structs, are copied about, so that 
> changing one does not change another.

Thank you for the reply, I think this explanation should be added 
to the top of https://dlang.org/spec/arrays.html

Then people (esp with C/C++ background) can easily understand D's 
array behavior.





More information about the Digitalmars-d-learn mailing list