(Pݴޠ͔Βݟͨ%%%ɹ
どういうこと?
type dog struct {
id uint
name string
}
func(d *dog) Cry() string {
return “Bow!"
}
type Animal interface {
Cry() string
}
func test(a Animal) {
fmt.Printf(a.Cry())
}
メソッドは構造体(struct)に紐付ける
Interfaceに定義されたメソッドと
同じものが定義された構造体はそ
のInterfaceとして使用できる