From: optman Date: 2007-09-07T13:45:05+09:00 Subject: Re: Where is the definition of File.read()? On 9 7 , 1 24 , John Joyce wrote: > On Sep 6, 2007, at 11:34 AM, Gregory Brown wrote: > > > On 9/6/07, optman wrote: > >> Where is the public class method File.read() defined? Which take a > >> file name as parameter, but what is in return? I have search all the > >> document and source code, just can't find the definition. > > >> Could anyone point me to the source file? I really want to know, > >> thanks in advance. > > > It actually inherits IO.read, IIRC > > > Source: > >http://www.ruby-doc.org/core/classes/IO.src/M002270.html > > Ruby methods normally return the last thing in the method. > File.read() will return the contents of the file. > > As others said, it inherits from class IO > Many people just use IO.read() instead because of this. > you can go into the site ruby directory inside of the ruby directory > (where you installed ruby) and open the File class files and read them. I have seen a line of code like put( File.read(sourceFile),targetFile) if File.read() return the entire file content, what if sourceFile is a large file?