From: MenTaLguY Date: 2007-10-20T05:57:00+09:00 Subject: Re: the level of Ruby programmers vs PHP's On Fri, 19 Oct 2007 17:34:29 +0900, SpringFlowers AutumnMoon wrote: > SpringFlowers AutumnMoon wrote: > >> print_debug(2**3) >> print_debug(8**(1.0/3)) >> print_debug(a + 2.038) >> [...] >> >> it will print out the expression as well as the value at the same time, >> as a convenience for testing and for debugging. > > so it is more like, printing out literally the expression of interest as > a string, and then the evaluated value. I think the best you can do in Ruby without resorting to ParseTree/Ruby2Ruby is something like this: print_debug {"2**3"} print_debug {"8**(1.0/3)"} print_debug {"a + 2.038"} ...where print_debug is implemented like this: def print_debug(&expr_block) expr = expr_block.call value = eval(expr, expr_block.binding) puts "#{expr} = #{value.inspect}" end Does that help? -mental