title: Ruby hash by reference
body: <p>I want to have a single target and then have that target be modifiable in a hash.</p>
  
  <pre><code>target = [1,2,3]
  hash = {1 =&gt; target, 2 =&gt; target}
  </code></pre>
  
  <p>Now, I want to be able to either a) change target and have the hash auto update or b) change the hash's 1 and have it automatically change hash's 2.  Neither work:</p>
  
  <pre><code>target = [6,7,8]
  target
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>{1=&gt;[1, 2, 3], 2=&gt;[1, 2, 3]}
  </code></pre>
  
  <p>Plan b:</p>
  
  <pre><code>hash[1] = [6,7,8]
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>{1=&gt;[6, 7, 8], 2=&gt;[1, 2, 3]}
  </code></pre>
  
  <p>So I'm discerning that when you make a subhash an rvalue in a hash in Ruby, it's duping the subhash before setting the lvalue to equal it.  What I want is the for Ruby to not to do that.  Is this possible?</p>
  
  <p>Thanks,
  Kevin</p>