开发者

Difference between an object and a dictionary?

开发者 https://www.devze.com 2023-02-06 16:11 出处:网络
What exactly is the difference between an object and a dictionary in Actionscript? var obj:Object = new Object();

What exactly is the difference between an object and a dictionary in Actionscript?

var obj:Object = new Object();
obj.something = "something";

var dict:Dictionary = new Dictionary();
dict.something = "someth开发者_开发问答ing";

trace(obj.something, dict.something);

The trace statement seems identical...


I think the example here highlights at least one of the most significant differences, which is strict equality in comparing keys.

In summary, dictionary[key] does NOT necessarily return the same value as dictionary["key"], even if key.toString() equals "key".

However, object[key] will return the same value as object["key"], if key.toString() equals "key".


Object() uses strings as keys, while Dictionary() uses objects as keys.

See http://gskinner.com/blog/archives/2006/07/as3_dictionary_.html

0

精彩评论

暂无评论...
验证码 换一张
取 消