Difference between is and ==
Suliman
evermind at live.ru
Tue Feb 4 00:25:16 PST 2014
> My interpretation of tdpl p57:
>
> 'is' compares for alias equality for arrays and classes.
> Otherwise they are the same.
So should next code have same behavior if I will use is instead
of ==
import std.stdio;
import std.string;
void main()
{
getchar();
}
void getchar()
{
string x;
if ((x = stdin.readln().chomp) == "q")
writeln("it's is q");
else
writeln("Not q");
}
In case I am using is, I have never get first if expression is
true.
More information about the Digitalmars-d-learn
mailing list