Unqualified class name
jfondren
julian.fondren at gmail.com
Sat Aug 21 21:48:12 UTC 2021
On Saturday, 21 August 2021 at 21:13:58 UTC, Jeremy T. Gibson
wrote:
> On Saturday, 21 August 2021 at 18:27:34 UTC, Ali Çehreli wrote:
>> return __traits(identifier, typeof(this));
>
> That works perfectly! Thanks. =)
This is exactly the solution you linked to in your first post,
and found wanting.
```d
class Whoami {
string name() {
return __traits(identifier, typeof(this));
}
}
class AnotherOne : Whoami { }
unittest {
assert((new Whoami).name == "Whoami");
assert((new AnotherOne).name == "Whoami");
}
```
More information about the Digitalmars-d-learn
mailing list