instance method
IO#readchar
() -> ::String
readchar → string
io.c
View on GitHub ↗
static VALUE
rb_io_readchar(VALUE io)
{
VALUE c = rb_io_getc(io);
if (NIL_P(c)) {
rb_eof_error();
}
return c;
}
Reads and returns the next 1-character string from the stream; raises EOFError if already at end-of-stream. See Character IO.
Example
f = File.open('t.txt') f.readchar # => "F" f.close f = File.open('t.rus') f.readchar.ord # => 1090 f.close