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

In Go it depends if the type is "comparable"; i.e. if "==" works.

You can use arrays in Go; e.g. map[[2]int]string, and you can also use channels; although I'm not sure what the rules for comparing channels are exactly off-hand (I'm struggling to come up with a scenario when this would be useful off-hand actually).

The big problem with slices and maps is that they can be modified. That is, what happens if you modify a slice after you used it as a map key? In slices this is worse than with maps because the backing array can change if you run out of cap space. And also, do you compare by value or identity? And again, what happens if either changes?

I'm not sure if it's possible to come up with a set of rules that wouldn't take people by surprise in at least some cases.



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

Search: