Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

IO#syswrite

(::_ToS object) -> ::Integer
syswrite(object) → integer

Writes the given object to self, which must be opened for writing (see Modes); returns the number bytes written. If object is not a string is converted via method to_s:

Example
f = File.new('t.tmp', 'w')
f.syswrite('foo') # => 3
f.syswrite(30)    # => 2
f.syswrite(:foo)  # => 3
f.close

This methods should not be used with other stream-writer methods.

See also #sysseek #tell #sysread #timeout also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0