Should this be correct behaviour?

Steven Schveighoffer schveiguy at yahoo.com
Thu Nov 29 13:07:51 PST 2007


"BCS" wrote
> Reply to Walter,
>
>> Janice Caron wrote:
>>
>>> float[] f = new float[1];
>>> float[] g = f.dup;
>>> assert(f == g); /* Passes */
>>>
>>> My question is, shouldn't the first assert also fail?
>>>
>> You are comparing two array *references* which point to the same
>> array.
>
> That dup should have copied. The references should not be equal.

my guess is the function to compare arrays of any type does a bit for bit 
compare?

from what I can see in the docs, comparing two arrays is only defined for 
strings.

-Steve 





More information about the Digitalmars-d mailing list