instance method
IO#getc
() -> ::String?
getc → character or nil
io.c
View on GitHub ↗
static VALUE
rb_io_getc(VALUE io)
{
rb_io_t *fptr;
rb_encoding *enc;
GetOpenFile(io, fptr);
rb_io_check_char_readable(fptr);
enc = io_input_encoding(fptr);
READ_CHECK(fptr);
return io_getc(fptr, enc);
}
Reads and returns the next 1-character string from the stream; returns nil if already at end-of-stream. See Character IO.
Example
f = File.open('t.txt') f.getc # => "F" f.close f = File.open('t.rus') f.getc.ord # => 1090 f.close
Related: IO#readchar (may raise EOFError).