(from https://issues.dlang.org/show_bug.cgi?id=13797 where it was proposed to add a new Phobos function for this)
tl;dr: appending an array to an array works fine today:
---
int[] arr;
arr ~= [0, 1, 2];
---
So I don't see any reason why the compiler couldn't be improved to accept this too:
---
int[] arr;
arr ~= 3.iota;
---
Custom data types can already do this with operator overloading, but this is not possible for built-in arrays.
The lowering should be trivial as D already allows ranges for `foreach`:
---
int[] arr;
foreach (e; 3.iota)
arr ~= e;
---
Comment #1 by robert.schadek — 2024-12-13T18:58:03Z