Hi -- On Thu, 19 Jun 2008, Cthulhu __ wrote: > > Still having some problems with this program. I'm getting a TypeError > when the value of > > dx, *dat = line.scan(/\d+/).map.compact > is nil > > Any suggestions on how to handle this? my current implementation looks > like this: > > raw_data = Array.new > File.foreach files_to_parse[i].to_s do |line| > idx, *dat = line.scan(/\d+/).map.compact! {|s| s.to_i} > raw_data[idx] = dat > end > > but if I include a conditional statement that excludes nil inside this > block > {|s| s.to_i} > > then the size of the array changes, which i need to avoid. There won't be any nils in the array resulting from line.scan(/\d+/). It will either be empty or contain strings. So you shouldn't need to compact it. That line is a bit tangled in general. What happens if you run Robert's code as posted? David -- Rails training from David A. Black and Ruby Power and Light: ADVANCING WITH RAILS June 16-19 Berlin ADVANCING WITH RAILS July 21-24 Edison, NJ See http://www.rubypal.com for details and updates!