From: Devi Web Development Date: 2007-09-08T09:01:56+09:00 Subject: Re: Accessing variable names in ruby ------=_Part_63823_10124582.1189209709472 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline try v.intern.to_s ------------------------------------------ Daniel Brumbaugh Keeney Devi Web Development Devi.WebMaster@gMail.com ------------------------------------------ On 9/7/07, Todd A. Jacobs wrote: > > I found myself trying to do a bit of ruby debugging, and was going crazy > trying to figure out how to display a variable's name instead of its > value in a string. There may be a more elegant way, but I found that > symbols did what I wanted: > > if $DEBUG > [:my_email, :my_resume, :my_logfile].each do |v| > $stderr.puts "DEBUG: #{v} = #{eval v.to_s}" > end > end > > Is there a better way? > > -- > "Oh, look: rocks!" > -- Doctor Who, "Destiny of the Daleks" ------=_Part_63823_10124582.1189209709472--