首页 > 其他 > 详细

Object与Dictionary的区别

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

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

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的区别

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!