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

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.


Unfortunately "comparable" is not an interface, and the default implementation (which you can't opt out of) sometimes panics.


Like in everything Go, you opt out by using a clever hack like having a nameless non comparable field in the struct. Oh yeah.




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

Search: