码迷,mamicode.com
首页 > 其他好文 > 详细

Object与Dictionary的区别

时间:2014-08-12 16:47:34      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:blog   io   for   ar   cti   div   代码   new   

看看这两端代码就知道了:

object的输出:

var a:Object = new Object();
var b:Object = new Object();
var c:Object=new Object()
var obj:Object = new Object();
obj[a] = 1;// obj["[object Object]"] = 1;    
obj[b] = 2;// obj["[object Object]"] = 2;    
obj[c] = 3;// obj["[object Object]"] = 2; 
for (var prop:String in obj)
{
	trace(prop);// traces: [object Object]    
	trace(obj[prop]);// traces: 2    
}

 Dictionary的输出:

import flash.utils.Dictionary; 

var a:Object = new Object(); 
var b:Object = new Object(); 

var dict:Dictionary = new Dictionary(); 
dict[a] = 1; // dict[a] = 1; 
dict[b] = 2; // dict[b] = 2; 

for (var prop:* in dict) { 
      trace(prop); // traces: [object Object], [object Object] 
      trace(dict[prop]); // traces: 1, 2 
}

 

Object与Dictionary的区别,布布扣,bubuko.com

Object与Dictionary的区别

标签:blog   io   for   ar   cti   div   代码   new   

原文地址:http://www.cnblogs.com/qshuyan/p/3907487.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!