From: Justin Collins Date: 2011-08-19T16:12:49+09:00 Subject: Re: switch string to object On 08/19/2011 12:03 AM, zuerrong wrote: > 2011/8/19 Josh Cheek: > >> hello, in this case, is a variable. Notice that you cannot assign `hello`, >> *itself* to a variable. Only the object that `hello` is pointing to (the >> string `"world"`) >> >> Anywhere you use hello, it will be implicitly dereferenced. It is the same >> as using the object that it is pointing to. So that means you simply need to >> do `puts hello` and it will print "world" >> > > So, no way to translate a string to a variable name? Thanks. > Not really any _good_ ways, at least not for local variables. You could always use eval though. For constants there is Module.const_get. For instance variables there is instance_variable_get. -Justin