0
interface If { ... } class Impl implements If { ... } function test(type:Class, obj) { return obj instanceof type; } test(If, new Impl());
在最后一行调用test
返回false,但它应该是true。我该如何做这个检查的权利,要求它必须在功能内?动态接口的ActionScript instanceof
真正的代码:
public function iterate(callback:Function, type:Class = null) {
for (var node:EntityListNode = beginNode; node != null; node = node.next) {
if (type == null || node.entity instanceof type) callback(node.entity);
}
}