Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

IO#print

ios.print → nil
ios.print(obj, ...) → nil

Writes the given object(s) to ios. Returns nil.

The stream must be opened for writing. Each given object that isn’t a string will be converted by calling its to_s method. When called without arguments, prints the contents of $_.

If the output field separator ($,) is not nil, it is inserted between objects. If the output record separator ($\) is not nil, it is appended to the output.

Example
$stdout.print("This is ", 100, " percent.\n")

produces:

This is 100 percent.
See also #pressed? #printf #pread #putc also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1