From: Kurt Euler Date: 2003-08-24T13:53:49+09:00 Subject: Wierd problem reading fields in a tab-delimitted row... Everyone-- A wierd problem occurs in Ruby 1.67, 1.68 and 1.8 (and probably other versions?): If I step through rows in a tab-delimited text file using code like this: IO.foreach("wierd.txt") { |x| field = x.chop.split("\t") if field[4] != "" puts "some_string" puts field[4] else puts "no_string" puts field[4] end } to read each line of a text file (wierd.txt) as in this example: string1string2string3string4 string4string5string6string8 string9string10string11 string12string13string14string15 I get this output: =================== no_string no_string some_string nil no_string =================== The question is, why does field[4] only get assigned nil in the 3rd line but some phantom non-"nil" value in the 1st, 2nd, and 4th lines? The general case I've found is that a nil value is read from a 'column' if there are no strings in any 'columns' to the right. Thanks if you can help! -Kurt