I can’t recall ever wanting that. (Though I did find it odd that it,
and puts, return nil for no seemingly good reason.)
Have you wished that, Trans? If so, I’d be interested in your use
Oh yes, lots of times. When I’m debugging code I sometimes want to see
the state of an object, but I don’t want to mess with the execution.
With complex statements this isn’t always straight forward. For
If I want to see the result of baz(x), I’d need to change it to
Well, the beauty of Ruby is that you can change that as you see fit!
But ther seems little reason for having a return value that matches
the value you want to output if you are outputting the value anyway.
The value hasn’t changed and is already located in it’s own little
object. Seems in Ruby it’s easy enough to pass that value to output
and to anywhere else you need it/ want it.
It’s made with C, but I don’t think it works like C.
Has anyone else every wished #p would passthru it’s argument? Ie. Work
Here is a version that also handles multiple parameters required for
correct automatic array building like in “a,b,c=p(1,2,3)”:
def p *args
args.length>1 ? args : args
If multiple parameters are given, let’s return the array we already
have. Don’t return an array if it’s just one parameter (the usual
case). Note that the case of no parameter results in nil returned