例如在以下示例中:
type Food interface {
Eat() bool
}
type vegetable_s struct {
//some data
}
type Vegetable *vegetable_s
type Salt struct {
// some data
}
func (p Vegetable) Eat() bool {
// some code
}
func (p Salt) Eat() bool {
// some code
}
是否Vegetable和Salt两者都满足Food,即使一个是指针,另一个直接是结构?
富国沪深
相关分类