I must be missing something obvious now, but I can’t figure out how to add elements to a dynamic array in D.
I have tried this, without success:
string[] links;
foreach(link; someOtherArray) {
// Do something with link ...
links[] = link; // Trying here to add to the links array
}
and this:
string[] links;
int i = 0;
foreach(link; someOtherArray) {
// Do something with link ...
links[i] = link; // Trying here to add to the links array
i++;
}
What is the correct way to do this?
Use the concat operator: a ~ b or a ~= b;
The right side can be an individual element or another array.