I don't like slices in D

Vitali notavailable at mail.com
Thu Oct 17 13:24:43 PDT 2013


On Thursday, 17 October 2013 at 20:01:37 UTC, David Nadlinger 
wrote:
> On Thursday, 17 October 2013 at 18:41:53 UTC, Vitali wrote:
>> void removeElement(ref int[] arr, int index) {
>>  arr = arr[0..index] ~ arr[index+1..$];
>> }
>
> If you know that 'arr' is the only reference to this piece of 
> data, you can use arr.assumeSafeAppend() to enable re-use of 
> the remaining storage: 
> http://dlang.org/phobos/object.html#.assumeSafeAppend
>
> David

This is maybe what I have missed. I will take a closer look on 
it. Thank you.

Thanks for every one who has posted here. I think the function 
mentioned by David Nadlinger will solve my problems.

That's all for today ^^.


More information about the Digitalmars-d mailing list