Flatten a range of static arrays

Dennis dkorpel at gmail.com
Fri Feb 7 20:13:57 UTC 2020


If I have an input range with element type `int[3]`, how do I 
easily turn it into a range of `int` so I can map it?
If it were an int[3][] I could simply cast it to an int[] before 
mapping, but I don't want to eagerly turn it into an array.
I thought of doing this:
```
range.map!(x => x[]).joiner.map!(x => x*2);
```

But it gives:
Error: returning x[] escapes a reference to parameter x, perhaps 
annotate with return

I tried doing:
```
map!((return x) => x[]) // same error
map!((return ref x) => x[]) // does not match, map.front is not 
an lvalue
```

I can easily work around it with some more code, but I wonder if 
someone knows an easy solution.


More information about the Digitalmars-d-learn mailing list