From: Gregory Brown Date: 2008-12-11T23:49:24+09:00 Subject: Re: P shows object values, so can u put P and value in txt? On Wed, Dec 10, 2008 at 10:53 PM, James M. Lawrence wrote: > > I'd like to randomly interject the under-appreciated technique of > printing an expression and its value, as opposed just the value. > > def show(&block) > expression = block.call.strip > result = eval(expression, block.binding) > printf("%-20s #=> %s\n", expression, result.inspect) > end Neat idea. Thanks for sharing. -greg -- Technical Blaag at: http://blog.majesticseacreature.com Non-tech stuff at: http://metametta.blogspot.com "Ruby Best Practices" Book now in O'Reilly Roughcuts: http://rubybestpractices.com