File as string


(Maurício) #1

Hi,

How can I open a file as a single string (with many \n inside) instead

of as an array of strings?

Thanks,
Maurício

(Nobuyoshi Nakada) #2

Hi,

···

At Fri, 5 Jul 2002 05:45:21 +0900, Maurício wrote:

How can I open a file as a single string (with many \n inside) instead

of as an array of strings?

open(file) {|f| f.read}

IO.read(file) # 1.7


Nobu Nakada


(George Ogata) #3

Maurício wrote:

Hi,

How can I open a file as a single string (with many \n inside) instead

of as an array of strings?

Thanks,
Maurício

Like this?:

File.open(‘filename’) {|f| f.read}