# How to use a variable reference another variable?

**URL:** <https://www.ruby-forum.com/t/how-to-use-a-variable-reference-another-variable/80740>\
**Category:** Ruby\
**Created:** [December 30, 2006, 8:50pm UTC](https://www.ruby-forum.com/t/how-to-use-a-variable-reference-another-variable/80740 "2006-12-30T20:50:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yuesefa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9f8e36/32.png) [@yuesefa](https://www.ruby-forum.com/u/yuesefa)\
**Post date:** [December 30, 2006, 8:50pm UTC](https://www.ruby-forum.com/t/how-to-use-a-variable-reference-another-variable/80740/1 "2006-12-30T20:50:36Z")

</div>

since variable names are not objects, is there any possible ways to do  
this? thank you!

---

<div class="post-metadata">

**Author:** ![yuesefa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9f8e36/32.png) [@yuesefa](https://www.ruby-forum.com/u/yuesefa)\
**Post date:** [December 30, 2006, 10:03pm UTC](https://www.ruby-forum.com/t/how-to-use-a-variable-reference-another-variable/80740/2 "2006-12-30T22:03:05Z")

</div>

> Given that Ruby doesn’t allow this, maybe the problem you want to solve  
> has a simple solution using another language feature. For what  
> purpose(s) would you want to use variable references?
> 
> Lionel

Just curious. i vaguely have heard of it before

---

<div class="post-metadata">

**Author:** ![yuesefa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9f8e36/32.png) [@yuesefa](https://www.ruby-forum.com/u/yuesefa)\
**Post date:** [December 30, 2006, 9:11pm UTC](https://www.ruby-forum.com/t/how-to-use-a-variable-reference-another-variable/80740/3 "2006-12-30T21:11:03Z")

</div>

Haofei W. wrote the following on 30.12.2006 20:50 :

> since variable names are not objects, is there any possible ways to do  
> this? thank you!

Given that Ruby doesn’t allow this, maybe the problem you want to solve  
has a simple solution using another language feature. For what  
purpose(s) would you want to use variable references?

Lionel

---

<div class="post-metadata">

**Author:** ![yuesefa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9f8e36/32.png) [@yuesefa](https://www.ruby-forum.com/u/yuesefa)\
**Post date:** [December 30, 2006, 10:31pm UTC](https://www.ruby-forum.com/t/how-to-use-a-variable-reference-another-variable/80740/4 "2006-12-30T22:31:21Z")

</div>

On 12/30/06, Haofei W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Given that Ruby doesn’t allow this, maybe the problem you want to solve  
> > has a simple solution using another language feature. For what  
> > purpose(s) would you want to use variable references?
> 
> Just curious. i vaguely have heard of it before

If you’re interested, I had a thread called “patching strings together  
to make a variable” a long while back which had some references to  
doing such tricks…
