From: Ralph Shnelvar Date: 2012-02-21T10:32:12+09:00 Subject: Re: Accessing a local variable through a symbol Darryl, Monday, February 20, 2012, 6:13:46 PM, you wrote: DLP> On Mon, Feb 20, 2012 at 8:03 PM, Ralph Shnelvar wrote: >> Darryl, >> >> Monday, February 20, 2012, 1:57:53 PM, you wrote: >> >> DLP> On Mon, Feb 20, 2012 at 3:49 PM, Ralph Shnelvar wrote: >>>> local_variables delivers a list of symbols of the local variables. �I'm trying to access the underlying values associated with that list. >> >> DLP> def foo >> DLP> � x = 5 >> DLP> � y = 9 >> DLP> � z = 9 >> >> DLP> � local_variables.each { |varname| puts "#{varname} evaluates to >> DLP> #{eval varname}"} >> DLP> end >> >> DLP> Try that. >> >> I get >> �in `eval': can't convert Symbol into String (TypeError) DLP> I didn't use any symbols. Please post the exact code you're using. You implicitly used symbols because local_variables produces an array of symbols. C:\Users\Ralph>irb irb(main):001:0> def bar irb(main):002:1> x = 5 irb(main):003:1> y = 9 irb(main):004:1> z = 9 irb(main):005:1> irb(main):006:1* p local_variables irb(main):007:1> end => nil irb(main):008:0> bar [:x, :y, :z] => [:x, :y, :z] -- Best regards, Ralph mailto:ralphs@dos32.com