Answer the question
In order to leave comments, you need to log in
Does Ruby have variable variables like PHP does?
In php there is a concept like variable variables
$a=5;
$b='a';
echo $$b => 5
Answer the question
In order to leave comments, you need to log in
no. it is possible to operate on variables through the functions instance_variable_get/instance_variable_set
However, as in the case of PHP, this is bad practice. Use hash maps.
You can do something like this (in my opinion, in any language in general)
a = 1
b = a
puts a #=> 1
puts b #=> 1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question