Getting a class' name, but not fully qualified?
Jeremy DeHaan
dehaan.jeremiah at gmail.com
Thu Mar 27 10:41:12 PDT 2014
On Thursday, 27 March 2014 at 10:01:40 UTC, JR wrote:
> On Thursday, 27 March 2014 at 06:16:04 UTC, Jeremy DeHaan wrote:
>> As the title says, I was wondering if there was a way to get
>> the classes name at runtime, but not its fully qualified name.
>> I want JUST the name of the class only.
>
> So for a given class Foo, you want to extract the string "Foo"?
>
> class Foo
> {
> unittest() {
> assert(typeof(this).stringof == "Foo");
> }
> }
>
> If that gets evaluated in runtime I guess you could store it in
> an enum.
typeof(this) gives its fully qualified name though. I was looking
for a way to get just the name of the class alone.
I guess I can do a little processing since it happens in debug
only, but I wanted to avoid it if possible. Thanks for the help,
guys!
More information about the Digitalmars-d-learn
mailing list