首页 > 代码库 > Object与Dictionary的区别
Object与Dictionary的区别
看看这两端代码就知道了:
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 }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。