Re: Difference between is and ==

2014-02-04 Thread Steven Schveighoffer
On Tue, 04 Feb 2014 03:08:28 -0500, Suliman wrote: What difference between if ((x = stdin.readln().chomp) is "q") and if ((x = stdin.readln().chomp) == "q") ? The first compares the pointer of the arrays. The second compares the contents of the array. Both check length as well for equality

Re: Difference between is and ==

2014-02-04 Thread bearophile
Suliman: What difference between if ((x = stdin.readln().chomp) is "q") and if ((x = stdin.readln().chomp) == "q") ? "is" performs a raw comparison of just the values, and the value of a string is its ptr and length field. While "==" compares their contents. So you want to use "==" here bec

Re: Difference between is and ==

2014-02-04 Thread Martijn Pot
On Tuesday, 4 February 2014 at 08:25:18 UTC, Suliman wrote: 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 m

Re: Difference between is and ==

2014-02-04 Thread Suliman
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

Re: Difference between is and ==

2014-02-04 Thread Martijn Pot
On Tuesday, 4 February 2014 at 08:08:30 UTC, Suliman wrote: What difference between if ((x = stdin.readln().chomp) is "q") and if ((x = stdin.readln().chomp) == "q") ? My interpretation of tdpl p57: 'is' compares for alias equality for arrays and classes. Otherwise they are the same.

Difference between is and ==

2014-02-04 Thread Suliman
What difference between if ((x = stdin.readln().chomp) is "q") and if ((x = stdin.readln().chomp) == "q") ?