Array slice length confusion
Tim Matthews
tim.matthews7 at gmail.com
Thu Jul 9 07:55:09 PDT 2009
Sorry I misread (lacking sleep). I can just re slice from the slice,
silly me.
import std.stdio;
void extendSlice(T)(ref T[] slice, uint extendCount)
{
slice = slice.ptr[0..slice.length+extendCount];
}
void main()
{
char[] a = "Hello".dup;
char[] b;
b = a[1..3]; //b is a view into a
writeln(a); //(Hello)
writeln(b); //(el)
extendSlice(b,1);
writeln(a); //(Hello)
writeln(b); //(ell)
}
More information about the Digitalmars-d-learn
mailing list