Consider I have a map %{}
where I have keys that are Decimal
.
Problematically, in Decimal 3 != 3.0
, so as a result, indexing on Decimal keys is unreliable, and requires the use of Decimal.eq?/2
to test equality.
Is there a way I can overload the map subscription operator, in order that indexing on Decimal actually uses eq?
instead ==
?
i.e. mymap[Decimal.new(3)] == mymap[Decimal.from_float(3.0)]
If there's another approach I'm missing (e.g. Protocols/macros/something else, please let me know!)