4 ms·
Go already supports generics - the hashmap is generic, and the array is generic. It's just you can't implement your own hashmap in Go, and make it compile time
by richardwhiuk 7y ago
Go already supports generics - the hashmap is generic, and the array is generic.
It's just you can't implement your own hashmap in Go, and make it compile time type safe.
- dataangel 7y ago> It's just you can't implement your own hashmap in Go, and make it compile time type safe. Then it doesn't support generics. That is the entire point of the feature.
- dirkg 7y agoC also supports generics - just use void * !! no, Go doesnt' support generics.
- takeda 7y agovoid * is the C's equivalent of interface {} it has little to do with generics although it can be used to work around lack of it. Perhaps there are other ways, but in C you have parametric polymorphism functionality through macros. That's why min() and max() are not functions but macros and they work with any type that can be compared, not just float64.