# Variable/reference question

**URL:** <https://discuss.rubyonrails.org/t/variable-reference-question/15148>\
**Category:** rubyonrails-talk\
**Created:** [July 1, 2007, 11:12am UTC](https://discuss.rubyonrails.org/t/variable-reference-question/15148 "2007-07-01T11:12:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Browning1](https://avatars.discourse-cdn.com/v4/letter/j/838e76/32.png) [@John\_Browning1](https://discuss.rubyonrails.org/u/John_Browning1)\
**Post date:** [July 1, 2007, 11:12am UTC](https://discuss.rubyonrails.org/t/variable-reference-question/15148/1 "2007-07-01T11:12:40Z")

</div>

Yes, previous\_plan is a reference to @customer\_plan and so changes  
with it. Instead of

> previous\_plan = @customer.plan

This should work with something like

previous\_plan = @customer.plan.dup

Which makes previous\_plan a copy rather than a reference.

Though not a huge deal, this to me is one of the more annoying and  
confusing bits of Ruby. It uses references in many places where I'd  
think it would just copy values. And the difference between dup and  
clone is poorly documented or mysterious or both.
