title: Changing value of ruby variables/references
body: <p>I just stumbled upon something i don't quite understand. I know that variables in ruby are references. So that awesome stuff is possible. But when i pass a variable to a method, it behaves strangely:</p>
  
  <pre><code>my_var_a = "nothing happend to me"
  my_var_b = "nothing happend to me"
  
  def parse_set(my_var_set)
    my_var_set = "my value changed"
  end
  
  def parse_sub(my_var_sub)
    my_var_sub.sub! /(.*)/, "my value changed"
  end
  
  parse_set(my_var_a)
  parse_sub(my_var_b)
  
  my_var_a # =&gt; "nothing happend to me"
  my_var_b # =&gt; "my value changed"
  </code></pre>
  
  <p>Can you explain to me why it works with <code>sub!</code> and <code>=</code> leaves the object unchanged? How can I avoid to use <code>sub!</code> but having the same result?</p>