is(this : myClass)

Jonathan M Davis newsgroup.d at jmdavisprog.com
Fri Oct 20 21:42:32 UTC 2017


On Friday, October 20, 2017 21:32:48 Patrick via Digitalmars-d-learn wrote:
> The compiler seems to reject the following code in a class method:
>
> bool test = is(this : myClass);
>
> Could some please explain this?

"this" is not a type. is(T : U) is true if T is implicitly convertible to U.
T and U must both be types. So, you need to use the types of this and
myClass, even if that's just is(typeof(this) : typeof(myClass)) rather than
explicitly using their types.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list