From: Joel VanderWerf Date: 2004-06-12T15:48:33+09:00 Subject: Re: Any way to get the calling method's binding? Austin McDonald wrote: > In the meantime, you could do this: > > def trace (expr) > LOG.debug "#{expr} = #{yield expr}" > end > > def something > x=5 > x=7 > trace "x+y", {|n| eval n} > end > > something => 12 def trace(&block) expr = block.call puts "#{expr} = #{eval(expr, block)}" end def something x = 5 y = 7 trace {"x + y"} end something # ==> x + y = 12