2008/4/7, Pan K. [email protected]:
I will try with
lines.each_with_index do | line, z|
You should change a lot more. For example, you have nested
invocations of gsub on the same line (albeit sometimes with a
#downcase so it’s probably not the same instance).
You also do not need the “file.close” because your block ensures the
file will be closed properly.
Also, I do not see how z can ever be a non Fixnum in your code. Are
you sure this is the code that produces the error? Do you happen to
have multiple threads all of them using a z which is defined outside
the code you show?
In your case I’d rather use #map instead of normal iteration since you
seem to be replacing line contents with something else.
Or wait, there seems to be a off by one error lurking: you use
1…lines.length for iteration, read lines[z-1] but later lines[z].
lines[z] does not exist for z==lines.length. You either need to
change logic or use the three dots range for iteration.