instance method
ARGF#putc
putc(object) → object
io.c
View on GitHub ↗
static VALUE
rb_io_putc(VALUE io, VALUE ch)
{
VALUE str;
if (RB_TYPE_P(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;
}
Writes a character to the stream. See Character IO.
If object is numeric, converts to integer if necessary, then writes the character whose code is the least significant byte; if object is a string, writes the first character:
Example
$stdout.putc "A" $stdout.putc 65
Output:
Example
AA