Re: subarray using returns nil

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs