From: "Wolfgang Nádasi-Donner" Date: 2007-08-29T01:34:49+09:00 Subject: Re: More convenient #p? Trans wrote: > Has anyone else every wished #p would passthru it's argument? Ie. Work > like this: > > def p(x) > puts x.inspect > x > end > > Is there any good reason that it shouldn't? I noticed this was in > Ruby's source code TODO list once, but it never came to pass for some > reason. > > Thanks, > T. I prefer the following modification, because it makes it easy to be a voyeur in method chains. irb(main):001:0> module Kernel irb(main):002:1> def my_p irb(main):003:2> p self irb(main):004:2> self irb(main):005:2> end irb(main):006:1> end => nil irb(main):007:0> %w{a b c d}.my_p.collect{|i|'<'+i+'>'}.my_p.reverse ["a", "b", "c", "d"] ["", "", "", ""] => ["", "", "", ""] Wolfgang Nádasi-Donner -- Posted via http://www.ruby-forum.com/.