The title is a bit confusing. But let me explain my problem.

Let's pretend to have a class called MyObj . This MyObj has a hashCode() function that produces an Int hashcode to work with Haxe maps as a key. Like so:

var mymap = new Map<MyObj,String>(); var myobj = new MyObj(my,params); mymap[myobj] = "whatever"; trace(mymap[myobj]); // works great and can print "whatever" from map

The above works great. However; when mapping to a new object of the same parameters it does not work.

trace(mymap[new MyObj(my,params)]); // does not work, returns null

When printing out and examining the entire map ( trace(mymap) ) it seems that every "new" object that is used as a key is actually a new "id" or "hashcode" (what ever Haxe does under the hood).

I even have the equals operator overloaded in MyObj (which can be an abstract type).

The question is, how can you retrieve elements from a map using different objects which contain the same values, as noted above.

how to make something like this work: