From: Steve Midgley Date: 2006-12-16T12:17:47+09:00 Subject: Re: Dynamic Variable Names Hi Chris, I'm not positive I understand precisely what you want, but if you want to store/access a variable via a String values, you can do this via "Module::eval" or other similar techniques: def test static = "static" dyno = "_dynamic1" data = "store me" eval(static+dyno+"='"+data+"'") # call it via hard code #call it dynamically eval("puts "+static+dyno) end test I think this gets you where you want to be. For some reason, calling "static_dynamic1" hard coded wasn't working for me but if you need to go both ways, I'm sure it's possible. Not also the weird use of quote marks in the eval code. You have to quote "one layer" deeper than the code - but that's probably the same PHP Best, Steve At 07:00 PM 12/15/2006, Chris Martin wrote: >Is it possible to create dynamic variable names in ruby? > >For example, in PHP it's done like this > >$a = 1; >${"myvar_{$a}"} = "some_value"; > ># $myvar_1 = "some_value" >?> > >I'm having a hard time finding anything relevant when searching, as >'dynamic' and 'variable' are used quite frequently in text mentioning >ruby. > >Thanks. > >-- >Chris Martin >Web Developer >Open Source & Web Standards Advocate >http://www.chriscodes.com/ > >