On Wed, May 16, 2012 at 01:07:54PM -0400, Steven Schveighoffer wrote: [...] > For example: > > auto str = "abcabc"; > assert(str[0..3] == str[3..$]); // pass > assert(str[0..3] is str[3..$]); // fail > > which is very counterintuitive. [...]
I don't find that counterintuitive at all. To me, 'is' concerns memory identity: are the two things actually one and the same _in memory_? (In this case, no, because they are different chunks of memory that just happens to contain the same values.) Whereas '==' concerns logical identity: do the two things represent the same logical entity? (In this case, yes, these two arrays contain exactly the same elements.) I'd argue that 99% of the time, what you want is logical identity (i.e., ==), not memory identity. T -- Stop staring at me like that! You'll offend... no, you'll hurt your eyes!
