« Busy Weekend | Main | Advanced CSS Techniques and Programmatic Skinning »

For Loop Foolishness

I spent way too long yesterday debugging a stupid typo all the while thinking maybe I'd stumbled across a compiler bug. The code in question:

for (var name:String in _data);
{
    trace(name, _data[name]);
}

In the debugger I could clearly see that my _data object had multiple dynamic properties but I only ever saw one value printed out. In retrospect it was code blindness that comes from working with too many languages that use semicolons at the end of lines. While semicolons are optional in ActionScript, I always put them on, so my eyes just kept skimming over the fact that at the end of the for loop I had a stray one kicking around. Removing it magically made everything work again.

Tags: bug code flex

Comments

I think i've spent a few hours on the same issue. Sometimes it's best to just get a fresh pair of eyes to look at it.