Jochen Voss
Jul 18, 2023, 10:35:38 PM (yesterday)
to golang-nuts
Dear all,
To implement the “eq” operator in a simple PostScript interpreter, I need to determine whether two maps are the same object.
This can be done by adding a new element to one map, and checking whether the new entry also appears in the second map, but as you can imagine, the resulting code is quite ugly. See https://go.dev/play/p/AfembYDt3en for an implementation of this idea.
Is there a better way?
Many thanks,
Jochen
Jason Phillips
Jul 18, 2023, 10:52:24 PM (yesterday)
to golang-nuts
You can also use the reflect package rather than (directly) reaching for unsafe. The reflect.DeepEqual function does something along the lines of: https://go.dev/play/p/IVt0Z-mxugh