Array slice length confusion
Tim Matthews
tim.matthews7 at gmail.com
Thu Jul 9 00:13:26 PDT 2009
BCS wrote:
> 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;
>
>
I know that but I when I said I was trying to extend the view I really
mean that I was just trying to extend the view. Also depending on what
news reader you use you should see that it branched off in a particular
direction to a solution.
More information about the Digitalmars-d-learn
mailing list