1234567891011121314151617 |
- // Go:
- type Flyer interface {
- Fly(w *Weather) (s string, err error)
- }
- func (p *Snoopy) Fly(w *Weather) (s string, err error) {
- w.Type = "VERY " + w.Type // side-effect, for demo purposes
- s = fmt.Sprintf("Snoopy sees weather '%s', cries '%s'", w.Type, p.Cry)
- fmt.Println(s)
- for _, flyer := range p.Friends {
- flyer.Fly(w)
- }
- return s, err
- }
|