To create a new I/O stream named ios, use the new method. : IO.new « File Directory « Ruby






To create a new I/O stream named ios, use the new method.


# The first argument is 1, which is the numeric file descriptor for standard input. 
# Standard input can also be represented by the predefined Ruby variable $stdin. 
# The optional second argument, w, is a mode string meaning "write."

ios = IO.new( 1, "w" )

ios.puts "IO, IO, it's off to the computer lab I go."

$stdout.puts "Do you copy?"

 








Related examples in the same category

1.I/O modes
2.Standard streams