From: matz@... (Yukihiro Matsumoto) Date: 2000-08-28T13:45:41+09:00 Subject: [ruby-talk:4617] Re: Class methods Hi, In message "[ruby-talk:4608] Class methods" on 00/08/28, Mark Slagell writes: |Reading the thread about regexp matches made me wonder about this: | | def File.read(s) | File.new(s).read(nil) | end | |Then File.new("filename").read(nil) could be written more simply and |readably as File.read("filename") -- rather like "atime" is implemented |both as a class method and an instance method. Are there reasons not to |do such things? (more methods => performance suffers, perhaps?) Well, I don't want to provide every method of IO/File as a class method like readlines/mtime. It's too clumsy. I'd like to provide useful ones. I felt that the method to open file and read a leading fixed sized content from it, then close the file, is not quite useful. But IO#read provides the feature to read whole content too. Now, I feel the class method to read whole content may be useful. Although, File::open(s).read will do the job (unclosed file will be closed by GC). matz.