slurp a file into an array without newlines

Discussion in 'Ruby' started by Dick Davies, Sep 29, 2005.

  1. Dick Davies

    Dick Davies Guest

    Coffee....not.....working.......

    what's a neater way of doing this?

    lines =3D File.new('sometextfile').readlines.map { |l| l.chomp }

    --
    Rasputin :: Jack of All Trades - Master of Nuns
     
    Dick Davies, Sep 29, 2005
    #1
    1. Advertising

  2. Dick Davies wrote:
    >
    > what's a neater way of doing this?
    >
    > lines = File.new('sometextfile').readlines.map { |l| l.chomp }
    >


    require 'rio'

    lines = rio('sometextfile').chomp.lines[]

    Gavin
     
    Gavin Sinclair, Sep 29, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wes Gamble
    Replies:
    7
    Views:
    132
    Lyle Johnson
    Mar 23, 2006
  2. Charles R. Thompson
    Replies:
    6
    Views:
    155
    Ben Liddicott
    Jan 13, 2004
  3. Tom Sliva
    Replies:
    7
    Views:
    115
    Tom Sliva
    Nov 23, 2004
  4. Replies:
    7
    Views:
    226
    Big and Blue
    Dec 30, 2005
  5. kj
    Replies:
    7
    Views:
    182
Loading...

Share This Page