snoopy2 350 B

1234567891011121314151617
  1. // Go:
  2. type Flyer interface {
  3. Fly(w *Weather) (s string, err error)
  4. }
  5. func (p *Snoopy) Fly(w *Weather) (s string, err error) {
  6. w.Type = "VERY " + w.Type // side-effect, for demo purposes
  7. s = fmt.Sprintf("Snoopy sees weather '%s', cries '%s'", w.Type, p.Cry)
  8. fmt.Println(s)
  9. for _, flyer := range p.Friends {
  10. flyer.Fly(w)
  11. }
  12. return s, err
  13. }