Unexpected result comparing to null

DLearner bmqazwsx123 at gmail.com
Mon Aug 23 13:00:36 UTC 2021


Hi

The code below compiles and runs producing 'Not null'.

```
void main()
{
    import std.stdio;

    int Var1;
    int* ptrVar;

    ptrVar = &Var1;

    if (ptrVar == null) {
       writeln("Null");
    } else {
       writeln("Not null");	
    }
}
```

However, should it not fail to compile, as '==' used instead of 
'is'?

Best regards


More information about the Digitalmars-d-learn mailing list