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

literally any data structure that stores different types similarly. hashmaps, linkedlists, vectors, binary trees (assuming you can bound on some ordering function), etc, then all the operations you expect to work on those data structures. You could also define mapping operations that work on the containing structure and don't care much about the specific type of the contents. There's a million and one uses for generics (polymorphism).

In Go, I believe you need to give up type safety to write these implementations, by using Interface{}



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

Search: