From: Dave Thomas Date: 2001-01-19T07:15:07+09:00 Subject: [ruby-talk:9527] Re: reading an entire file as a string Mathieu Bouchard writes: > On Thu, 18 Jan 2001, Yukihiro Matsumoto wrote: > > > 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 > > This is like: > > File.open(path) {|f| f.read(*args) } Except because of scope you have to write buff = nil File.open(path) {|f| buff = f.read(*args) } Which is a bit uglier than buff = File.read(path) Dave