From: Siep Korteling Date: 2008-02-28T07:06:06+09:00 Subject: Re: checking for blank line Justin Collins wrote: > Jeff Miller wrote: (...)> > Also, using split on an empty string is not going to give you nil, but > an empty array: > > irb(main):003:0> "".split(":") > => [] > Yes, but array[0] will return nil if array is empty, so the OP is doing ok. > If you don't want the line endings in your strings, try using > > while (line = file.gets.chomp) This is too early, it will error when you get to the end of the file. One line later is fine: @array = line.chomp.split(':') > or > > while (line = file.gets.strip) > > > instead. > > -Justin Regards, Siep -- Posted via http://www.ruby-forum.com/.