title: Ruby object references
body: <p>I came across a snippet of code in Ruby that confused me. Boiling it down to a simple example below to illustrate. Why is it that sArr does not have its contents automatically updated in the first case but it happens in the second case? The snippets are short and self explanatory with three returns separating the two scenarios.</p>
  
  <pre><code>2.0.0-p598 :068 &gt; str = "Hello"
  =&gt; "Hello" 
  2.0.0-p598 :069 &gt; sArr = [str]
  =&gt; ["Hello"] 
  2.0.0-p598 :070 &gt; str = str.upcase
  =&gt; "HELLO" 
  2.0.0-p598 :071 &gt; str
  =&gt; "HELLO" 
  2.0.0-p598 :072 &gt; sArr
  =&gt; ["Hello"]  # Why is this not ["HELLO"] like in the sequence below?
  2.0.0-p598 :073 &gt; 
  2.0.0-p598 :074 &gt;   
  2.0.0-p598 :075 &gt;   
  2.0.0-p598 :076 &gt;   str = "Hello"
  =&gt; "Hello" 
  2.0.0-p598 :077 &gt; sArr = [str]
  =&gt; ["Hello"] 
  2.0.0-p598 :078 &gt; str.upcase!
  =&gt; "HELLO" 
  2.0.0-p598 :079 &gt; sArr
  =&gt; ["HELLO"] 
  </code></pre>