3 ms·
> I do see your point: a slice could hold the type of its elements and then you'd have to prove that no other types are stored in the slice. But that's not real
by djhworld 14y ago
> I do see your point: a slice could hold the type of its elements and then you'd have to prove that no other types are stored in the slice. But that's not really simple either.
It's simple in typesafe languages that support generics/parametric polymorphism
- danieldk 14y agoIt's simple in typesafe languages that support generics/parametric polymorphism That's a different thing. The function is then instantiated to that particular type. []interface{} is more akin to an array of base class pointers. Except that in Go the type is stored with the pointer to the actual data.