Comparing Instances of Classes

Whatsthisnow via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Mar 10 09:08:42 PST 2017


On Friday, 10 March 2017 at 16:47:47 UTC, Adam D. Ruppe wrote:
> On Friday, 10 March 2017 at 16:36:17 UTC, DRex wrote:
>> I'm fairly new to D, but this seems to be quite a pain in the 
>> rear for a simple comparison of instances of classes...really 
>> odd that comparing instances of classes in D requires that 
>> messing around when D seems all about simplifying things...
>
> There often is no sensible default comparison for class 
> contents (now structs on the other hand do have a default 
> comparison that usually works, but structs don't have to worry 
> about polymorphism), so you just need to specify what fields 
> actually matter to your code...

I guess i am just too used to the java way of x.equals(object) 
which at the source  is exactly 'return this == object'


More information about the Digitalmars-d-learn mailing list