box-o-sand/oldstuff/c&s20150725/demo.go

32 lines
472 B
Go
Raw Normal View History

2015-07-25 17:53:04 +00:00
package main
import "fmt"
type Person struct {
Name string
}
func NewPerson(name string) *Person {
return &Person{
Name: name,
}
}
func (p *Person) Wave() string {
return p.Name + " is waving"
}
func (p *Person) WaveAt(other *Person) string {
return p.Name + " waves at " + other.Name
}
func main() {
boo := NewPerson("Boo")
fmt.Printf("%#v\n", boo.Wave())
hay := NewPerson("Hay")
fmt.Printf("%#v\n", hay.Wave())
fmt.Printf("%#v\n", boo.WaveAt(hay))
}