instanceof?

Maxime Chevalier maximechevalierb at gmail.com
Wed Aug 1 18:59:01 PDT 2012


Getting started with D. I've been doing alot of googling trying 
to find out what's the best way to check if an object is an 
instance of some class. So far, I found you could do:

if (typeid(obj) == typeid(Class)) doSomething();

or:

if (cast(Class)obj) doSomething();

These both seem a little clumsy, however. Is there a better way 
to do this?


More information about the Digitalmars-d-learn mailing list