End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
IO#close
ios.close → nil
io.c
View on GitHub ↗
static VALUE
rb_io_close_m(VALUE io)
{
rb_io_t *fptr = rb_io_get_fptr(io);
if (fptr->fd < 0) {
return Qnil;
}
rb_io_close(io);
return Qnil;
}
Closes ios and flushes any pending writes to the operating system. The stream is unavailable for any further data operations; an IOError is raised if such an attempt is made. I/O streams are automatically closed when they are claimed by the garbage collector.
If ios is opened by IO.popen, close sets $?.
Calling this method on closed IO object is just ignored since Ruby 2.3.
See also
#clear_screen
#closed?
#check_winsize_changed
#close_on_exec=
also in
4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1