Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
StringIO#write
(*::_ToS) -> ::Integer
strio.write(string, ...) → integer
strio.syswrite(string) → integer
ext/stringio/stringio.c
View on GitHub ↗
static VALUE
strio_write_m(int argc, VALUE *argv, VALUE self)
{
rb_len_t len = 0;
while (argc-- > 0) {
/* StringIO can't exceed rb_len_t limit */
len += strio_write(self, *argv++);
}
return LEN2NUM(len);
}
Appends the given string to the underlying buffer string. The stream must be opened for writing. If the argument is not a string, it will be converted to a string using to_s. Returns the number of bytes written. See IO#write.