title: How does negative index work with `Array#[]=`?
body: <p>I tried to see how <code>Array#[]=</code> works, and played around:</p>
  
  <pre><code>enum[int] = obj → obj
  enum[start, length] = obj → obj
  enum[range] = obj → obj
  </code></pre>
  
  <p><strong>Question 1</strong></p>
  
  <p>I have one array <code>b</code> holding <code>nil</code> at its <code>0</code> index.</p>
  
  <pre><code>b = []
  b[0]   # =&gt; nil
  </code></pre>
  
  <p>I tried to replace <code>nil</code> with integer <code>10</code> in the code below.</p>
  
  <pre><code>b[-1] = 10 # =&gt; IndexError: index -1 too small for array; minimum: 0
  </code></pre>
  
  <p>Why doesn't the code above work, but the ones below do? In case of an array with size <code>1</code>, why are the indices <code>0</code> and <code>-1</code> treated differently?</p>
  
  <pre><code>b[0] = 5   # =&gt; 5
  b[-1] = 10 # =&gt; 10
  </code></pre>
  
  <p><strong>Question 2</strong></p>
  
  <p>I created an array of size <code>2</code>, and did the following:</p>
  
  <pre><code>a = [1,2]
  
  a[-3] = 3       # =&gt; IndexError: index -3 too small for array; minimum: -2
  a[-3] = [3]     # =&gt; IndexError: index -3 too small for array; minimum: -2
  a[-3..-4] = [3] # =&gt; RangeError: -3..-4 out of range
  </code></pre>
  
  <p>I believe that negative index never increases the size of an array, but I don't know why. Why did the code below succeed?</p>
  
  <pre><code>a[-2..-3] = [3,4] #=&gt; [3, 4]
  </code></pre>