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/.