Array slice length confusion

BCS none at anon.com
Wed Jul 8 21:50:48 PDT 2009


Hello Tim,

> Anyway I like how you can get a slice of array that is just a view
> into the original. If I modify the slice, it modifies the full
> original array which can be very useful. If however I modify the
> length of the slice which I was doing in an attempt to extend the
> view, it becomes it's own array.
> 
[...]
>
> Was this a design choice, bug, undefined behavior, etc...?
> 

you can grab a larger chunk like this


char[] buff1 = something;
char[] buff2 = buff1[10..20];

buff2 = buff2.ptr[0..20];

note this is unsafe and will give you no warnings if you extend past the 
end of buff1;




More information about the Digitalmars-d-learn mailing list