在 Flex 中计算字典长度 [英] Calculating Dictionary length in Flex

查看:32
本文介绍了在 Flex 中计算字典长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Flex 中计算 Dictionary 对象长度的最佳方法是什么?

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";

我想检查这个字典的长度应该是 2.除了遍历对象之外,还有什么方法可以做到吗?

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?

推荐答案

不,除了遍历元素之外,没有办法检查对象的长度(字典几乎是一个支持非字符串键的对象).

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.

这篇关于在 Flex 中计算字典长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆