End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
IO#readchar
ios.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 a one-character string from ios. Raises an EOFError on end of file.
Example
f = File.new("testfile") f.readchar #=> "h" f.readchar #=> "e"