public Method

Kernel.print(...)

print(obj, ...)     nil

Prints each object in turn to $stdout. If the output field separator ($,) is not nil, its contents will appear between each field. If the output record separator ($\) is not nil, it will be appended to the output. If no arguments are given, prints $_. Objects that aren’t strings will be converted by calling their to_s method.

print "cat", [1,2,3], 99, "\n"
$, = ", "
$\ = "\n"
print "cat", [1,2,3], 99

produces:

cat12399
cat, 1, 2, 3, 99

Source Code

/*
*  call-seq:
*     print(obj, ...)    => nil
*  
*  Prints each object in turn to <code>$stdout</code>. If the output
*  field separator (<code>$,</code>) is not +nil+, its
*  contents will appear between each field. If the output record
*  separator (<code>$\\</code>) is not +nil+, it will be
*  appended to the output. If no arguments are given, prints
*  <code>$_</code>. Objects that aren't strings will be converted by
*  calling their <code>to_s</code> method.
*     
*     print "cat", [1,2,3], 99, "\n"
*     $, = ", "
*     $\ = "\n"
*     print "cat", [1,2,3], 99
*     
*  <em>produces:</em>
*     
*     cat12399
*     cat, 1, 2, 3, 99
*/

static VALUE
rb_f_print(argc, argv)
   int argc;
   VALUE *argv;
{
   rb_io_print(argc, argv, 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.