[LRUG] Array.slice question
    Tom Stuart 
    tom at therye.org
       
    Wed Sep  7 01:58:15 PDT 2011
    
    
  
On 7 September 2011 09:52, Tom Stuart <tom at therye.org> wrote:
> The special case listed in the docs is actually even more interesting, since the length value in that case is 1. In this case, the test '(RARRAY_LEN(ary) < len || RARRAY_LEN(ary) < beg + len)' passes, and the length gets adjusted to 'length of array - start value', i.e. 0. (line 956) I'm struggling to see why that logic is there - it can't be there just to support the call x[n, 1] where n == x.size, can it?
>
> Cheers,
>
> Other Tom
>
Ah, I see it now. It's to support e.g. x(4..7) when x.size == 5, as
per the docs again. In that case, it's supposed to return x[4] and any
other elements up to the end, so it returns a subset of length x.size
- 4, starting at x[4].
    
    
More information about the Chat
mailing list