From: ptkwt@...1.aracnet.com (Phil Tomson) Date: 2002-11-20T05:30:28+09:00 Subject: Re: Symbol usage help In article , ahoward wrote: > > >rubyists- > >given > > a = 42 > b = 'forty-two' > >is it possible to do something like : > > %w( a b ).each do |s| > puts "#{s} = #{s.intern.value}" > end > >to output > > a = 42 > b = forty-two > >obviously, the Symbol#value method does not exist, but this should be clear >enough... How about?: irb(main):013:0> %w( a b ).each do |s| irb(main):014:1* puts "#{s} = #{eval s}" irb(main):015:1> end a = 42 b = forty-two But actually, you're list doesn't contain symbols but strings which stand for the names of your two variables a, and b. So 's' above isn't a Symbol but a String. probably what you really want is: [:a,:b].each do |s| puts #{s} = #{eval s.id2name} end Phil