Method: IO#<<

Defined in:
io.c

#<<(object) ⇒ self

Writes the given object to self, which must be opened for writing (see Access Modes); returns self; if object is not a string, it is converted via method to_s:

$stdout << 'Hello' << ', ' << 'World!' << "\n"
$stdout << 'foo' << :bar << 2 << "\n"

Output:

Hello, World!
foobar2

Returns:

  • (self)


2349
2350
2351
2352
2353
2354
# File 'io.c', line 2349

VALUE
rb_io_addstr(VALUE io, VALUE str)
{
    rb_io_write(io, str);
    return io;
}