public Method

IO.putc(p1)

ios.putc(obj)     obj

If obj is Numeric, write the character whose code is obj, otherwise write the first character of the string representation of obj to ios.

$stdout.putc "A"
$stdout.putc 65

produces:

AA

Source Code

/*
*  call-seq:
*     ios.putc(obj)    => obj
*  
*  If <i>obj</i> is <code>Numeric</code>, write the character whose
*  code is <i>obj</i>, otherwise write the first character of the
*  string representation of  <i>obj</i> to <em>ios</em>.
*     
*     $stdout.putc "A"
*     $stdout.putc 65
*     
*  <em>produces:</em>
*     
*     AA
*/

static VALUE
rb_io_putc(io, ch)
   VALUE io, ch;
{
   char c = NUM2CHR(ch);

   rb_io_write(io, rb_str_new(&c, 1));
   return ch;
}
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.