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

Go Generics work differently than those in Java. They are specialized, meaning that they are not generic at runtime anymore. Instead, the compiler creates a different implementation for each type.

At runtime, there are only List[int], List[string], etc. List[T] is not a thing anymore.



The one thing I hated about Java's generics was type erasure. It worked for the JVM but it had such stupid limits, like not being able to switch on a type, like go. (interfaces are types, this is exploitable)




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

Search: