Use classes as keys in associative array

ag0aep6g anonymous at example.com
Sat Jun 6 16:57:38 UTC 2020


On Saturday, 6 June 2020 at 16:49:29 UTC, JN wrote:
> Is it possible to use different class instances as keys for 
> associative array, but compare them by the contents? I tried to 
> override opEquals but it doesn't seem to work.

You also need toHash.

https://dlang.org/spec/hash-map.html#using_classes_as_key


More information about the Digitalmars-d-learn mailing list