From: Stephen Duncan Date: 2007-02-20T09:56:26+09:00 Subject: Re: Strange question: Convert string to array name I'm still pretty much a newbie, but my first thought that works is: eval('bobo')[2] -Stephen On 2/19/07, kenbo wrote: > I am coming to Ruby from LISP where I was more competent when it came > to symbol > manipulation :-) I have spent some time trying to solve this problem > and figure it's my > general lack of deep knowledge ala Ruby that keeps me from seeing an > "easy" solution. > > With that said, I apologize if this has been answered and I missed > it. > > I have a string in a variable. > foo = "bobo" > > I want to use foo to access an array called bobo. I will have bobo > defined already. > > Is there a way to do this? > > Take foo and use it to access bobo[2], for example. > > I thought about turning foo into a symbol, but that wasn't the way. > And, I think there > should be a way to ask Ruby to return an object via its string name, > but I am > missing the way. > > any advice would be appreciated. > > > kenny > > > -- Stephen Duncan Jr www.stephenduncanjr.com