3 ms·
Go cheats with some built-in generic types. So you can declare a hashtable as a map of any comparable type to any other type. But yes you typically have to impl
by shirro 6y ago
Go cheats with some built-in generic types. So you can declare a hashtable as a map of any comparable type to any other type. But yes you typically have to implement things yourself for more complex cases so that does limit the sorts of libraries that are available and the way you write programs.
- erik_seaberg 6y agoUnfortunately "comparable" is not an interface, and the default implementation (which you can't opt out of) sometimes panics.
- pjmlp 6y agoLike in everything Go, you opt out by using a clever hack like having a nameless non comparable field in the struct. Oh yeah.