2 ms·
Sort of, except the way Java did it is awkward because they put a method on Object instead of making it an interface. It's not clear from the API what's really
by skybrian 4y ago
Sort of, except the way Java did it is awkward because they put a method on Object instead of making it an interface. It's not clear from the API what's really usable as a map key.
I'm not sure making all comparable objects in Go usable as map keys is a good idea either.
- masklinn 4y ago> I'm not sure making all comparable objects in Go usable as map keys is a good idea either. Was a good idea since, it's part of the spec-definition of Go: > A map is an unordered group of elements of one type, called the element type, indexed by a set of unique keys of another type, called the key type. [...] The comparison operators == and != must be fully defined for operands of the key type TFA is merely reusing that.