Danny Wilson
2007-05-16 12:10:37 UTC
---
--- I think this one got lost, so i'm resending it ---
---
Hi Nicolas,
I'm trying to figure out how to properly check if a class implements an
interface...
interface Bla {
public var x : String;
}
class Test implements Bla
{
public var x : String;
public function new(){}
public static function main()
{
switch(Type.typeof(new Test())){
case TClass(c):
var a : Array<Dynamic> = untyped c.__interfaces__;
for(i in a) if(i == Bla) trace('yay');
default:
}
}
}
This works, but a simple "new Test() instanceof Bla" would be much
prettier ;-)
--- I think this one got lost, so i'm resending it ---
---
Hi Nicolas,
I'm trying to figure out how to properly check if a class implements an
interface...
interface Bla {
public var x : String;
}
class Test implements Bla
{
public var x : String;
public function new(){}
public static function main()
{
switch(Type.typeof(new Test())){
case TClass(c):
var a : Array<Dynamic> = untyped c.__interfaces__;
for(i in a) if(i == Bla) trace('yay');
default:
}
}
}
This works, but a simple "new Test() instanceof Bla" would be much
prettier ;-)
--
haXe - an open source web programming language
http://haxe.org
haXe - an open source web programming language
http://haxe.org