Why D is annoying =P

Walter Bright newshound2 at digitalmars.com
Wed Oct 24 13:31:14 PDT 2012


On 10/24/2012 12:17 PM, Mehrdad wrote:
 > I couldn't find a better title, sorry.
 >
 >
 > But yeah, I've spent too many hours on hunting down problems like these...
 >
 >
 > Could someone explain what's going on? Thanks!
 >
 > import std.stdio;
 > struct S { int[int] aa; }
 > void main()
 > {
 >      writeln(  [1: 2]  ==   [1: 2] );  // true
 >      writeln(S([1: 2]) == S([1: 2]));  // false
 > }
 >
 > (I'm on Windows DMD v2.060.)

The compare for associative arrays is to compare the members.

The default compare for structs is a bit compare of the contents.


More information about the Digitalmars-d mailing list