On Sep 18, 4:59   㮮 
> Is there a way in Ruby to use the content of a variable as the name of a
> variable.   >
> var1 = 'myVar'
>
> i want to assign a value to 'myVar' by referencing var1.    
> the variable can vary depending on the content of var1.  
> application include using a variable to hold the name of a class method
> which i need to call in my code.

With eval you can do quite a bit:

====

v_name = "my_var"
v_value = "5"

eval "#{v_name} = #{v_value}"
eval "puts my_var"

# note: generates
error
puts my_var rescue puts "error"

my_var = 0  # now initialize the variable in current
binding

eval "#{v_name} = #{v_value}"
eval "puts my_var"

# no error
now
puts my_var

====

Eric

====

Are you interested in on-site Ruby or Ruby on Rails training
that uses well-designed, real-world, hands-on exercises?
http://LearnRuby.com