I don't like slices in D

Dicebot public at dicebot.lv
Fri Oct 18 07:33:53 PDT 2013


On Friday, 18 October 2013 at 14:29:44 UTC, Dicebot wrote:
> On Friday, 18 October 2013 at 14:27:36 UTC, Adam D. Ruppe wrote:
>>    for(size_t idx = index; idx < arr.length - 1; idx++)
>>        arr[idx] = arr[idx + 1];
>
> You can do it via slice element-wise assignment:
>
> arr[index..$-1][] = arr[index+1..$][]

Ah, nvm, it will trigger an exception for overlapping source and 
dest.


More information about the Digitalmars-d mailing list