From: luke gruber Date: 2011-08-14T01:53:46+09:00 Subject: Re: How to get the Name of a Variable I'll cheat by not using a closure... but here's what I came up with. class Test yummy = "cereal" @function = lambda do |arg| puts "The value of arg is " + arg local_variables.each do |var| if eval(var.to_s) == arg && var != :arg puts "The name of arg is " + var.to_s end end nil end p @function.call(yummy) end If there are lots of local variables in scope then it'd be a good idea to memoize them. Using a hash still makes the most sense though. -Luke -- Posted via http://www.ruby-forum.com/.