From: "Guy N. Hurst" Date: 2000-10-20T16:45:57+09:00 Subject: [ruby-talk:5702] variable variables Hi, I am wondering if ruby has an equivalent to PHP's variable variables. For example, in PHP, if you set $x="myvar", then $$x will be equivalent to $myvar, so you could set $myvar indirectly by setting $$x: $myvar == "hi" ?> I know you can call eval() in ruby to get the value: x="myvar" myvar="hi" eval(x) -> "hi" But that is not quite the same thing. How do I assign myvar by using x? Is using Hash the only way? hash={} hash['x']="myvar" hash[hash['x']]="hi" p hash['myvar'] #-> "hi" I would appreciate any pointers. ;-) ---- A similar feature in PHP is extract(), which takes an associative array and puts the keys into the symbol table with the associaated values as the contents of each newly generated variable. $first="Who" and $third="I don't know" ?> This is something I use all the time in PHP. I'm not sure how it might work in Ruby since variables are not the same between the two... Thanks, Guy N. Hurst -- HurstLinks Web Development http://www.hurstlinks.com/ Norfolk, VA - (757)623-9688 PHP/MySQL - Ruby/Perl - HTML/Javascript