On 1/20/22 5:07 PM, forkit wrote:
On Thursday, 20 January 2022 at 21:16:46 UTC, forkit wrote:
Cannot work out why I cannot pass valuesArray in as ref const??
get error: Error: cannot append type `const(int[])[const(int)]` to type
`int[][int][]`
Because it would allow altering const data.
e.g.:
```d
const(int[])[const(int)] v = [1: [1, 2, 3]];
int[][int][] arr = [v]; // assume this works
arr[0][1][0] = 5; // oops, just set v[1][0]
```
General rule of thumb is that you can convert the HEAD of a structure to
mutable from const, but not the TAIL (the stuff it points at).
An associative array is a pointer-to-implementation construct, so it's a
reference.
-Steve