Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

class method

IO.open

IO.open(fd, mode="r" [, opt]) → io
IO.open(fd, mode="r" [, opt]) {|io| block } → obj

With no associated block, IO.open is a synonym for IO.new. If the optional code block is given, it will be passed io as an argument, and the IO object will automatically be closed when the block terminates. In this instance, IO.open returns the value of the block.

See IO.new for a description of the fd, mode and opt parameters.

See also .new .pipe .for_fd .popen also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1