title: Special cases of Ruby array slicing
body: <p>Document for <a href="https://ruby-doc.org/core-2.2.0/Array.html#method-i-slice" rel="nofollow noreferrer"><code>Array#slice</code></a> says:</p>
  
  <blockquote>
    <p>[A]n empty array is returned when the starting index for an element range is at the end of the array. </p>
    
    <p>Returns nil if the index (or starting index) are out of range.</p>
  </blockquote>
  
  <p>Having this in mind,</p>
  
  <pre><code>a = ["a","b","c","d","e"]
  
  a[6,1]   # =&gt; nil
  a[5,1]   # =&gt; []
  a[5..10] # =&gt; []
  </code></pre>
  
  <p>why does <code>a[5,1]</code> and <code>a[5..10]</code> return an empty array given that <code>5</code> is not the end of the array? It should be out of index, hence it should return <code>nil</code>.</p>