Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



> 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: