From: John Mair Date: 2012-07-05T21:47:33+09:00 Subject: Re: question: p expression 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: # [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 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) > => # > > http://www.ruby-doc.org/core-1.9.3/Kernel.html#method-i-p -- Posted via http://www.ruby-forum.com/.