23 October 2014

Hip Hip Array!

I had a script working absolutely fine (by which I mean it worked "mostly fine"), and then I made some changes to it which involved the inclusion of some diagnostics.

And then the Bad Things began.

My script was basically building multiple arrays by collecting data and indexing it non-sequentially.  Instead of assigning data to my_array[ 0 ], followed by my_array[ 1 ], then my_array[ 2 ], I would first collect data for my_array[ 5 ], followed by data for my_array[ 3 ], and so forth.

My diagnostics printed out all of the data collected by the arrays, and that data was incorrect.  "Math," I cursed, and started debugging.  Socks recently supported negative indexes (which means instead of writing my_array[ index - 1 ], I could instead just write my_array[ -1 ] ), and I was convinced that my array index pointer was somehow falling into a negative number.  I added more diagnostics.  The correct answers were being displayed correctly with these new diagnostics, but the data was still wrong within the summarized diagnostics.

Three days of debugging and I found the problem: my script was absolutely fine, but my summary diagnostics were looking at the wrong sets of data types.  Once I corrected that, then all of the data matched.

I am such a chucklehead sometimes.

No comments:

Post a Comment