前のやつ Go言語でジェネリクスっぽいことがしたいでござる【generics】【golang】 - DRYな備忘録 の続きっていうかメモ /***** * Go言語で型変数を受けるCollectionみたいなの *****/ package main import "fmt" import "reflect" type E struct { element interface{} score int } func (e *E) Elem() interface{} { return e.element } type Collection struct { representative interface{} elements []E } func (c *Collection) Push(v interface{}) (e error) { if reflect.TypeOf(c.repr
![Go言語でジェネリクスっぽいことしたいでござるの続き【golang】【generics】 - DRYな備忘録](https://cdn-ak-scissors.b.st-hatena.com/image/square/138648fda04fcab38f63cd2c16c2d703553e4fd4/height=288;version=1;width=512/http%3A%2F%2Fcdn-ak.f.st-hatena.com%2Fimages%2Ffotolife%2Fo%2Fotiai10%2F20140618%2F20140618135125.jpg)