I’m seeing a really weird issue with this code and sample execution: https://gist.github.com/720278
The data in the two files is identical, but for some reason the app fails on the second file. Running the app only for this file works fine, it only breaks when multiple files are processed in one execution. The exceptions are not helping me track things down at all (complaining about map()s which work fine normally).
I was hoping someone might have seen something like this before and could point me in the right direction.
Your code works in MRI 1.9, but not in MRI 1.8.7. The problem, in this case, comes from a difference in how string subscripting works.
This method intends to separate comments from data by examining the first character of each line using
line[0]. In Ruby 1.9, this returns the first character as a string. in Ruby <1.9, however, this returns the first character as an integer. For this to work in older versions of ruby, useline[0..0]instead ofline[0]:You may find it more succinct to use a regular expression to test for a comment:
line =~ /^#/. The methodArray#partitionwill also play well here:With your updates to the git tree, it runs for me without error, when processing multiple files, and when running twice in a row.