Dirk Einecke <dirk.einecke / gmx.de> writes:

> Hi.
>
> Well - thanks to all. Now I've several ways:
>
> 1.
> value = open(path) {|f| f.read}
>
> 2.
> file = File.open(path, File::RDONLY)
> value = file.read
> file.close
>
> 3.
> value = File.readlines(path).to_s
>
> 4.
> value = File.readlines(path).join
>
> What is the fastes way (for Ruby) and what should I use?
>
> greetings
> Dirk Einecke

In my opinion, number one is the best.  The latter two only make sense
for line-based formats, and even in such cases it's easier to just read
it all in at once.  Number two, I assume, is just like number one,
except you have to close it up yourself, which is annoying.

  mikael