Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between an object and a dictionary?

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

trace(obj.something, dict.something);

The trace statement seems identical...

like image 948
redconservatory Avatar asked Jan 22 '11 02:01

redconservatory


2 Answers

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

like image 103
Zach L Avatar answered Sep 22 '22 01:09

Zach L


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

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

like image 30
joeforker Avatar answered Sep 19 '22 01:09

joeforker