Reputation: 6305
I have the following line in my code:
static if (typeof(val) == string) {
It is not compiling and returning the error Error: incompatible types for ((string) == (string)): cannot use '==' with types
. What is the correct way to check the type of a variable?
Upvotes: 4
Views: 585
Reputation: 25605
The correct way to do it is to use an is
expression around it: is(A == b)
like this:
static if (is(typeof(val) == string)) {
Upvotes: 8