I am really stumbling a lot into quirks of programming languages. I mean, something like "0x0" == "0", which turns out to be a true condition in PHP is quite hilarious. I found this while trying to figure out what PHP is doing when comparing values. So that's an artificially found quirk.
But this here, this is simply beyond me:
var t = {};
t['0'] = "test";
for (k in t) {
if ('0'!==k) trace("AS sucks");
}
This is not JS, even if it looks alike. It is Actionscript 3. And you already guess what this is printing out "AS sucks". I mean come on. I am putting a string with a string key into the object and the KEY is converted to a NUMBER, just because it looks like one. YES! FFS, who is the brilliant genius came up with *that* idea? This is really one of the worst sins I have ever seen. The type coercion in JS and PHP is already one of the worst (basic) ones ever - worst because they are totally avoidable. And the benefit is zero. But THIS, this is a completely failure. This is not just a quirk - no, this means that if an object is used as a dictionary that comparing keys turns out to be a bug hole (you guess how I stumbled over that crap). It's already stupid that JS converts all keys to strings, no matter of its type, but at very least, it's consistent in that behavior. But this AS the normal behavior is plainly completely mind boggling.
Yes, I am most likely not the first one to find this out, but well... doesn't matter. Just wanted to shout this out. What a sucking failure.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment