putc(p1)
public
If obj is Numeric, write the character whose code is the
least-significant byte of obj, otherwise write the first byte of the string representation
of obj to ios. Note: This method is not safe for use with
multi-byte characters as it will truncate them.
$stdout.putc "A"
$stdout.putc 65
produces:
AA
Show source
static VALUE
rb_io_putc(VALUE io, VALUE ch)
{
VALUE str;
if (TYPE(ch) == T_STRING) {
str = rb_str_substr(ch, 0, 1);
}
else {
char c = NUM2CHR(ch);
str = rb_str_new(&c, 1);
}
rb_io_write(io, str);
return ch;
}