3 ms·
That's a very weak argument since you're already opting out of every other kind of compiler check by using `interface{}` as an element type to begin with. Yet
by cjslep 7y ago
That's a very weak argument since you're already opting out of every other kind of compiler check by using `interface{}` as an element type to begin with.
Yet another reason to just use `interface{}`: if the caller already has a value of type `[]Concrete` then they can just pass it in directly; otherwise the caller will need to allocate and copy the value's elements into a new value of `[]interface{}` type since the `[]Concrete` is not castable: https://play.golang.org/p/whh1mAAlN-N https://play.golang.org/p/whh1mAAlN-N
- tsimionescu 7y agoMy point was that it is a bad idea to write functions that take an interface{} and try to reflect on it, since you are putting out of all compiler checks. You also get a much, much slower function.