上QQ阅读APP看书,第一时间看更新
The empty interface
Another alternative would be to use the empty interface like so:
type Object interface{}
type Collection []Object
func (list Collection) Contains(e string) bool {
for _, t := range list { if t == e { return true } }
return false
}
However, reflection or typecasting would be required and that would again adversely affect the performance.