I'm doing something like this:
I have an interface
type Hero interface {
Fly()
Fight()
}
And these struct:
type Bat struct {}
func (b *Bat) Fly() {}
type Man struct {}
func (m *Man) Fight() {}
type BatMan struct {
*Bat
*Man
}
Fly()
Fight()
}
And these struct:
type Bat struct {}
func (b *Bat) Fly() {}
type Man struct {}
func (m *Man) Fight() {}
type BatMan struct {
*Bat
*Man
}
so I can:
var h Hero = BatMan{}
OK, its normal, but then I try:type BatMan2 struct {
Bat
Man
}
var batman *BatMan2Man
}
var h Hero = batman
Its ok too!
It confusing me, "*batman*" is a pointer to the *BatMan2*, but in *BatMan2*there is no pointer to
*Bat* and *Man*, so how can "*batman*" can Fly() and Fight()?
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.