views:

134

answers:

1
interface If { ... }
class Impl implements If { ... }

function test(type:Class, obj) {
  return obj instanceof type;
}

test(If, new Impl());

The call to test on the last line returns false, but it should be true. How can I do this check right, with the requirement that it must be inside the function?


Real code:

    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);
        }   
    }
A: 

if(Object is IInterface) ... works fine for that AFAIK.

Theo.T