From: zuerrong Date: 2011-08-19T16:20:05+09:00 Subject: Re: switch string to object Thanks for all the helps. I now got the idea. 2011/8/19 Bartosz DziewoƄski : > You can just use eval(). > > hello = "world" > puts eval("hello") > > This is, however, a bad idea, especially if the eval'd string comes > from the user. You should never have to do that. > > -- Matma Rex > > > > 2011/8/19 zuerrong : >> 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. >> >> > >