Calculating Dictionary length in Flex

calvinf picture calvinf · Apr 1, 2009 · Viewed 13.4k times · Source

What's the best way to calculate the length of a Dictionary object in Flex?

var d:Dictionary = new Dictionary();
d["a"] = "alpha";
d["b"] = "beta";

I want to check the length which should be 2 for this Dictionary. Is there any way to do it other than looping through the objects?

Answer

CookieOfFortune picture CookieOfFortune · Apr 1, 2009

No, there is no way to check the length of an object(Dictionary is pretty much an object that supports non-String keys) other than looping through the elements.

http://www.flexer.info/2008/07/31/how-to-find-an-objects-length/

You probably don't have to worry about checking if the property is an internal one.