I'm puzzled by the fact that, if an array is sliced at it length
, it returns an empty array, but at a length greater than that, it returns nil
. What is the reason for this? For example:
arr = [1,2,3,4,5]
Doing this, where y > arr.length
and x
is any positive integer, returns nil
:
arr[y, x] # => nil
but doing the following returns []
arr[5, x] # => []
Since arr[5]
doesn't exist, shouldn't it return nil
as well?