You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
472 B

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))
}