Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
StringIO#eof?
() -> bool
eof? → true or false
ext/stringio/stringio.c
View on GitHub ↗
static VALUE
strio_eof(VALUE self)
{
if (strio_to_read(self)) return Qfalse;
return Qtrue;
}
Alias of #eof
Returns whether self is positioned at end-of-stream:
Example
strio = StringIO.new('foo') strio.pos # => 0 strio.eof? # => false strio.read # => "foo" strio.pos # => 3 strio.eof? # => true strio.close_read strio.eof? # Raises IOError: not opened for reading
Related: StringIO#pos.