new(...)
public
Returns a new IO
object (a stream) for the given integer file descriptor and mode string.
See also IO#fileno and IO::for_fd.
a = IO.new(2,"w")
$stderr.puts "Hello"
a.puts "World"
produces:
Hello
World
Show source
/*
* call-seq:
* IO.new(fd, mode_string) => io
*
* Returns a new <code>IO</code> object (a stream) for the given
* integer file descriptor and mode string. See also
* <code>IO
*
* a = IO.new(2,"w")
* $stderr.puts "Hello"
* a.puts "World"
*
* <em>produces:</em>
*
* Hello
* World
*/
static VALUE
rb_io_s_new(argc, argv, klass)
int argc;
VALUE *argv;
VALUE klass;
{
if (rb_block_given_p()) {
const char *cname = rb_class2name(klass);
rb_warn("%s::new() does not take block; use %s::open() instead",
cname, cname);
}
return rb_class_new_instance(argc, argv, klass);
}