From text file to array in shortest way

books_array = Array.new()
File.open('books_file.txt').each { |line|
     books_array.push(line)
}

Are there other ways shorter than above ?
For example: books_array = File.open('books_file.txt').to_array()

a = IO::read 'books_file.txt'

-a

···

On Tue, 8 Nov 2005, ngoc wrote:

books_array = Array.new()
File.open('books_file.txt').each { |line|
   books_array.push(line)
}

Are there other ways shorter than above ?
For example: books_array = File.open('books_file.txt').to_array()

--

email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
anything that contradicts experience and logic should be abandoned.
-- h.h. the 14th dalai lama

===============================================================================

Ara.T.Howard wrote:

···

On Tue, 8 Nov 2005, ngoc wrote:

books_array = Array.new()
File.open('books_file.txt').each { |line|
   books_array.push(line)
}

Are there other ways shorter than above ?
For example: books_array = File.open('books_file.txt').to_array()

a = IO::read 'books_file.txt'

-a

you just misspelled 'readlines', right? :slight_smile:

cheers

Simon

indeed.

thanks.

-a

···

On Tue, 8 Nov 2005, [ISO-8859-1] Simon Kröger wrote:

Ara.T.Howard wrote:

On Tue, 8 Nov 2005, ngoc wrote:

books_array = Array.new()
File.open('books_file.txt').each { |line|
   books_array.push(line)
}

Are there other ways shorter than above ?
For example: books_array = File.open('books_file.txt').to_array()

a = IO::read 'books_file.txt'

-a

you just misspelled 'readlines', right? :slight_smile:

--

email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
anything that contradicts experience and logic should be abandoned.
-- h.h. the 14th dalai lama

===============================================================================