ts <decoux / moulon.inra.fr> writes:
> IO::readlines("path", nil)
> and you have an array with only 1 element, which contains the entire
> contents of a file

Thanks for pointing out an alternative, but compare:

IO.readlines ("path", nil)[0]
  vs
IO.readlines ("path").join
  vs
File.new("path").read
  vs
IO.read("path")

The File version is also a bit "unclean" in that the file object is
temporarily left open. [But in practice, as pointed out in my earlier note,
this doesn't seem to be a problem even when opening a lot of files.]

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.)

Regards,
Raja