From: Mike Dvorkin Date: 2006-09-11T06:44:26+09:00 Subject: Re: patching strings together to make a variable I'm not quite clear what exactly you're trying to achieve, but you can perform any operation on $variable by making it part of eval() string: puts eval('$' + 'var' + 'iable += 1') #=> 2 puts eval('$' + 'var' + 'iable *=' + 10.to_s) #=> 20 HTH :-) Mike Dvorkin http://www.rubywizards.com On Sep 10, 2006, at 1:22 PM, Sy Ali wrote: > On 9/10/06, Mike Dvorkin wrote: >> How about: >> >> puts "#{eval('$' + 'var' + (if $a == true then "iable" end))}" >> # => pass > > > I can see the value with this, but what if I wanted to add a number to > the resulting variable? > > Something like this: > > a = "var" > b = "iable" > $variable = 1 > eval('$' + 'var' + 'iable') += 1 >