[Issue 346] New: 'is' operator inconsistant with arrays
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Sep 12 21:42:58 PDT 2006
http://d.puremagic.com/issues/show_bug.cgi?id=346
Summary: 'is' operator inconsistant with arrays
Product: D
Version: 0.166
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P3
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: ibisbasenji at gmail.com
It has been my understanding that the 'is' operator, when working with types
other than objects, is an alias for the '==' operator. (For template
simplicity, as I recall.) However, the following code illustrates a case where
it is different in behavior. (My apologies if this is not really a bug, but I
don't know what else to call it.)
--------------------------------------------------
import std .stdio ;
void main () {
static int[] foo = [1, 2, 3] ,
bar = [1, 2, 3] ;
int[] def = foo;
if (foo == bar) writefln(" foo == bar");
if (foo is bar) writefln(" foo is bar");
if (foo == def) writefln(" foo == def");
if (foo is def) writefln(" foo is def");
}
--------------------------------------------------
Outputs:
foo == bar
foo == def
foo is def
--
More information about the Digitalmars-d-bugs
mailing list