# Re: subarray using returns nil

**URL:** <https://www.ruby-forum.com/t/re-subarray-using-returns-nil/112902>\
**Category:** Ruby\
**Created:** [August 24, 2007, 10:44am UTC](https://www.ruby-forum.com/t/re-subarray-using-returns-nil/112902 "2007-08-24T10:44:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [August 24, 2007, 10:44am UTC](https://www.ruby-forum.com/t/re-subarray-using-returns-nil/112902/1 "2007-08-24T10:44:12Z")

</div>

Hi Todd

The operation b = a[1,-1] is a slice operation where the first index is  
the start point and the second is the length of the array that you are  
retrieving - this is why you are getting nil for ‘b’ - the way to do  
this would be to use an inclusive range like this b = a[1…-1] - this  
will return the results that you expect.
