rcom10002 / ccgclient

Automatically exported from code.google.com/p/ccgclient
0 stars 1 forks source link

删除HashMap, IMap #34

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
如果没有用了,就从info.knightrcom.util中删除

var x:* = new Object();

x["key1"] = "value";
x["key2"] = new Date();
x["key3"] = new Array();

Alert.show(x["key1"]);

ps:ActionScript中每个对象都可以动态添加属性的,你随便创建��
�个Object,就可以把它当Map用的

Original issue reported on code.google.com by rcom10002 on 19 Aug 2009 at 1:39

GoogleCodeExporter commented 9 years ago
但要是改的话如何判断x对象中是否包含有key1这个键,处理起
来是不是很麻烦!

Original comment by songjie8...@gmail.com on 20 Aug 2009 at 8:58

GoogleCodeExporter commented 9 years ago
var x:Object = new Object();
var y:Object = new Object();
x["a"] = null;
x["b"] = null;
y["a"] = undefined;
trace(x["a"]);
trace(x["b"]);
trace(y["a"]);
trace(y["b"]);
trace(x["a"] == y["a"]);
trace(x["a"] === y["a"]);
======RESULT======>>>
null
null
undefined
undefined
true
false

比较操作符===代表的是值与类型比较,就是说,左右两个参��
�比较的内容,不光需要值一样,类型也必须一样,而操
作符==仅仅是对值的比较

如果你对一个Map中的元素个数不关心的话,没必要引入外部��
�Map类,即便有要求可以自己写个简单的,
MyMap["size"] = 
0;每次新增或删除一个元素的时候MyMap["size"]++或MyMap["size"]--

x["a"] = null; // 新增属性
x["b"] = undefined; // 删除一个存在的属性
if (x["b"] === undefined) { .. } // 判读属性不存在 ===
if (x["b"]) { .. } // 
只要x["b"]的内容为null或undefined,if语句就会把值转换成false

这套理论适用于JavaScript

Original comment by rcom10002 on 20 Aug 2009 at 9:26

GoogleCodeExporter commented 9 years ago
null代表你所引用的变量或属性什么的存在,但它所指向的值�
��不存在的

undefined意味着你所引用的变量或属性根本没在当前程序关联��
�中定义

Java中

String[] strings = new String[1];
string[0]; // null, a defined element with no values specified
string[1]; // undefined and an exception will be thrown

Original comment by rcom10002 on 20 Aug 2009 at 9:30

GoogleCodeExporter commented 9 years ago
http://www.flashinsider.com/2005/07/25/null-equals-undefined-but-null-doesn-t-st
rictly-
equal-undefined/

Original comment by rcom10002 on 20 Aug 2009 at 9:33

GoogleCodeExporter commented 9 years ago
已经删除了,改成你提供的这种方法,已测试没问题

Original comment by songjie8...@gmail.com on 21 Aug 2009 at 5:26