T
Todd A. Jacobs
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?
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?