On Friday, 20 October 2017 at 21:42:32 UTC, Jonathan M Davis wrote:
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

Thank you.

Due to the very specific nature of the 'is' operator, why wouldn't the compiler know to implicitly query the class types? Why must it be explicitly written, typeof(this)?

Patrick

Reply via email to