Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
class method
IO.open
IO.open(fd, mode = 'r', **opts) → io
IO.open(fd, mode = 'r', **opts) {|io| ... } → object
io.c
View on GitHub ↗
static VALUE
rb_io_s_open(int argc, VALUE *argv, VALUE klass)
{
VALUE io = rb_class_new_instance_kw(argc, argv, klass, RB_PASS_CALLED_KEYWORDS);
if (rb_block_given_p()) {
return rb_ensure(rb_yield, io, io_close, io);
}
return io;
}
Creates a new IO object, via IO.new with the given arguments.
With no block given, returns the IO object.
With a block given, calls the block with the IO object and returns the block’s value.