[#4567] Re: What's the biggest Ruby development? — Aleksi Niemel<aleksi.niemela@...>

Dave said:

18 messages 2000/08/23
[#4568] Q's on Marshal — Robert Feldt <feldt@...> 2000/08/23

[#4580] RubyUnit testcase run for different init params? — Robert Feldt <feldt@...> 2000/08/25

[#4584] Re: RubyUnit testcase run for different init params? — Dave Thomas <Dave@...> 2000/08/25

Robert Feldt <feldt@ce.chalmers.se> writes:

[#4623] Re: RubyUnit testcase run for different init params? — Robert Feldt <feldt@...> 2000/08/28

On Sat, 26 Aug 2000, Dave Thomas wrote:

[#4652] Andy and Dave's European Tour 2000 — Dave Thomas <Dave@...>

24 messages 2000/08/30
[#4653] Re: Andy and Dave's European Tour 2000 — matz@... (Yukihiro Matsumoto) 2000/08/30

Hi,

[#4657] Ruby tutorials for newbie — Kevin Liang <kevin@...> 2000/08/30

Hi,

[ruby-talk:4617] Re: Class methods

From: matz@... (Yukihiro Matsumoto)
Date: 2000-08-28 04:45:41 UTC
List: ruby-talk #4617
Hi,

In message "[ruby-talk:4608] Class methods"
    on 00/08/28, Mark Slagell <ms@iastate.edu> 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.

In This Thread