From: Tim Hunter Date: 2008-09-19T06:27:09+09:00 Subject: Re: variable name Rick Tan wrote: > Is there a way in Ruby to use the content of a variable as the name of a > variable. For example > > var1 = 'myVar' > > i want to assign a value to 'myVar' by referencing var1. The name of > the variable can vary depending on the content of var1. Other > application include using a variable to hold the name of a class method > which i need to call in my code. > > Thanks in advance In general, no. Most of the time this problem can be solved by using a hash. That is, var1 = 'myVar' hsh[var1] = value In the specific case of calling a method whose name is in a variable, use send: var1 = 'my_method' obj.send(var1, arg1, arg2,...) -- RMagick: http://rmagick.rubyforge.org/