Like getClass()
Sergey Gromov
snake.scaly at gmail.com
Sat Sep 27 12:54:43 PDT 2008
Sat, 27 Sep 2008 19:50:18 +0200,
torhu wrote:
> obj.classinfo doesn't work the way you'd expect with an interface, but
> it works when you've got an object:
>
> writefln((cast(Object)thing).classinfo.name);
Thanks for the tip! It seems like classinfo of an interface contains
information about the most derived interface implemented in an object:
interface a {}
interface aa : a {}
class A : aa {}
void main() {
writefln((cast(a) new A).classinfo.name);
}
prints "test.aa". Though this functionality is of questionable
usefulness (has anybody used it for something?) and besides it's broken:
interface a {}
interface aa : a {}
class A : a, aa {}
void main() {
writefln((cast(a) new A).classinfo.name);
}
prints "test.a" even though A implements the "aa" interface as well.
More information about the Digitalmars-d-learn
mailing list