Comparing pointers with "is"
monarch_dodra
monarchdodra at gmail.com
Mon Aug 27 08:51:02 PDT 2012
When comparing pointers, is there any difference when writing:
int* p1, p2;
if(p1 == p2) {...}
if(p1 is p2) {...}
?
My guess would be that no, there isn't *but*:
*Using "==" shows the *intent* of comparing the pointer values?
*Using "is" shows the *intent* of checking if the pointed objects
are the same?
Either that, or is it considered "best practice" to use "is" to
compare pointers, because "==" and "is" have a different meaning
in the context of using classes?
More information about the Digitalmars-d-learn
mailing list