How to find out if an interface is implemented?
Asked Answered
B

2

5

How can I find out if an object implements an interface? In other words I need a possibility to check if an object can be cast to a specific type (e.g. a specific interface).

Becht answered 27/8, 2012 at 10:11 Comment(0)
C
9

Std.is(). Or use a safe cast and it will throw an error if it fails.

Communalism answered 27/8, 2012 at 10:26 Comment(0)
C
-1

you can try to create the object and catch with a class not found exception i guess.

Clementina answered 27/8, 2012 at 10:20 Comment(1)
i want to check an existing object, if it implements an interface. i can do a cast and catch an exception, but that can't be the ultimate answer...Becht

© 2022 - 2024 — McMap. All rights reserved.