read(...) public

Reads at most length bytes from the I/O stream, or to the end of file if length is omitted or is nil. length must be a non-negative integer or nil. If the optional buffer argument is present, it must reference a String, which will receive the data.

At end of file, it returns nil or "" depend on length. and returns "". returns nil.

   f ="testfile")   #=> "This is line one"
Show source
Register or log in to add new notes.