From: David Alan Black Date: 2002-07-18T20:23:28+09:00 Subject: Re: How to name a variable after another variable's value? Hello -- On Thu, 18 Jul 2002, Norbert Gawor wrote: > Kurt Euler wrote: > > I tried to do something like this: > > greeting_no = "2" > > sp#{greeting_no}_greeting = 'Hello' > > greeting_no = "2" > eval "sp#{greeting_no}_greeting = 'Hello'" I agree that using a Hash is almost certainly a much better design -- but I just want to point out that in the above example, the variable you create that way will only be visible in the eval block: $ ruby -vwe 'a="b"; eval "#{a}=1; puts b"; puts b' ruby 1.6.7 (2002-03-01) [i686-linux] 1 -e:1: undefined local variable or method `b' for # (NameError) David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav