public Method

Kernel.p(...)

p(obj, ...)     nil

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

<em>produces:</em>

<S name="dave", state="TX">

Source Code

/*
*  call-seq:
*     p(obj, ...)    => nil
*  
*  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
*     
*  <em>produces:</em>
*     
*     #<S name="dave", state="TX">
*/

static VALUE
rb_f_p(argc, argv)
   int argc;
   VALUE *argv;
{
   int i;

   for (i=0; i<argc; i++) {
       rb_p(argv[i]);
   }
   if (TYPE(rb_stdout) == T_FILE) {
       rb_io_flush(rb_stdout);
   }
   return Qnil;
}
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.