April 2012
1 post
[]T is not []I
It’s bothered me for a while now that in Go I can’t assign a []T to an []I, where T is a concrete type implementing the I interface. But recently I learned of a very good reason. Consider this code: type Shape interface { Area() int } type Circle interface { Area() int Radius() int } type Square interface { Area() int Width() int Height() int } func main() { var circles...
Apr 1st