Hi,

I am trying to compare two instances of a class. I created a test program to try this, but every method I use to compare the instances always returns false.

this is my code to test comparison

class A
{
    this()
    {

    }
}

void main()
{
    A a = new A();
    A a2 = new A();

    writeln(equals(a, a2));
}

bool equals(Object obj1, Object obj2)
{
    return (obj1 is obj2);
}

I have tried 'a is a2', I have tried 'a1 == a2' and many other ways (including opEquals from object.d) among other things and every single time the comparison returns false. The comparison always fails and never returns true.

I am trying to do something like Object.equals(Object o) in java, but so far, no success.

Am I missing something here?

Reply via email to