Method: IO#write
- Defined in:
- io.c
#write(*objects) ⇒ Integer
Writes each of the given objects to self, which must be opened for writing (see Access Modes); returns the total number bytes written; each of objects that is not a string is converted via method to_s:
$stdout.write('Hello', ', ', 'World!', "\n") # => 14
$stdout.write('foo', :bar, 2, "\n") # => 8
Output:
Hello, World!
foobar2
Related: IO#read.
2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 |
# File 'io.c', line 2289
static VALUE
io_write_m(int argc, VALUE *argv, VALUE io)
{
if (argc != 1) {
return io_writev(argc, argv, io);
}
else {
VALUE str = argv[0];
return io_write(io, str, 0);
}
}
|