Not very useful :P

You can also do this in Pry:

[37] (pry) main: 0> ? p

From: io.c (C Method):
Number of lines: 11
Owner: Kernel
Visibility: private
Signature: p(*arg1)

For each object, directly writes
_obj_.inspect followed by the current output
record separator to the program's standard output.

   S = Struct.new(:name, :state)
   s = S['dave', 'TX']
   p s

produces:

   #<S name="dave", state="TX">
[38] (pry) main: 0> $ p

From: io.c (C Method):
Number of lines: 20
Owner: Kernel
Visibility: private

static VALUE
rb_f_p(int argc, VALUE *argv, VALUE self)
{
    int i;
    VALUE ret = Qnil;

    for (i=0; i<argc; i++) {
    rb_p(argv[i]);
    }
    if (argc == 1) {
    ret = argv[0];
    }
    else if (argc > 1) {
    ret = rb_ary_new4(argc, argv);
    }
    if (TYPE(rb_stdout) == T_FILE) {
    rb_io_flush(rb_stdout);
    }
    return ret;
}
[39] (pry) main: 0>


Lars Haugseth wrote in post #1067498:
> On 07/05/2012 10:29 AM, smoothedatol412 @gmail.com wrote:
>> Lately I have been going through some Ruby books and I keep coming up on
>> an script like the following:
>>
>> hash={"A"=>10, "B"=>20, "C"=>30}
>> p hash.keys() # what is this
>>
>> What is this p method or expression I keep coming across?
>
> [1] pry(main)> method(:p)
> => #<Method: Object(Kernel)#p>
>
> http://www.ruby-doc.org/core-1.9.3/Kernel.html#method-i-p

-- 
Posted via http://www.ruby-forum.com/.