Hi,
In message "[ruby-talk:9465] Re: reading an entire file as a string"
on 01/01/18, Dave Thomas <Dave / PragmaticProgrammer.com> writes:
|> Reading the entire contents of a file as a string is a common enough
|> operation. We have the instance methods #read and #readlines. Was curious
|> about the asymmetry in that we only have the class method IO.readlines .
|> (Of course, we could write our own IO.read but was wondering why it isn't
|> in the language itself.)
|
|I'd vote for this in 1.6.3/1.7. I've found myself wanting it too.
OK. But unlike readlines and each, read is not fundamentally for
reading whole file. What kind of method do you want?
(a) exactly like:
f = open(path)
begin
f.read(*args)
ensure
f.close
end
(b) takes no argument, to read whole file always.
(c) something else.
Once the spec is fixed, it's no problem to add in 1.7.
matz.