title: Referencing array index in Ruby
body: <p>I was under impression that references in Ruby are equivalent to pointers in C.  But I'm confused by this:</p>
  
  <pre><code>ar = [1, 2, 3, 4]
  first = ar[0] # =&gt; 1
  ar.shift # =&gt; 1
  ar # =&gt; [2, 3, 4]
  first # =&gt; 1
  </code></pre>
  
  <p>Shouldn't <code>first</code> point to the memory address of <code>ar[0]</code>,  which holds the value <code>2</code>? Why does it still hold to the expired value?</p>
  
  <p>What is the Ruby way to let <code>first</code> equal to the current value of <code>ar[0]</code>?</p>