title: How does .insert work?
body: <p>I'm trying to figure out what the <code>insert</code> function does in Ruby. </p>
  
  <p>I've consulted Google and ruby-doc.com but the explanation is not sufficient to describe this (seemingly) mysterious function. </p>
  
  <p>Here's what's confusing me:</p>
  
  <pre><code>a = %w{a b c d}
  puts a.insert(4, 5)  output = a,b,c,d,5
  </code></pre>
  
  <p>The first question raised is, why is the 4 not inserted?</p>
  
  <pre><code>puts a.insert(2,2,6)
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>a
  b
  2
  6
  c
  d
  </code></pre>
  
  <p>Two questions raised by this are</p>
  
  <ol>
  <li>Why is 2 not inserted twice?</li>
  <li>Why are 2 and six (seemingly) arbitrarily placed between b and c?</li>
  </ol>