APIdock / Ruby
/
method

write

ruby latest stable - Class: IO
write(*args)
public

Writes the given strings to ios. The stream must be opened for writing. Arguments that are not a string will be converted to a string using to_s. Returns the number of bytes written in total.

count = $stdout.write ("This is", " a test\n")
puts  "That was #{count} bytes of data"

produces:

This is a test
That was 15 bytes  of data
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);
 }
}

AltStyle によって変換されたページ (->オリジナル) /