I don't like slices in D
David Nadlinger
code at klickverbot.at
Thu Oct 17 13:01:35 PDT 2013
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
More information about the Digitalmars-d
mailing list