type Cat struct {
name string
age int
location string
}
func (cat Cat) Grow(){
fmt.Println("grow")
}
func (cat *Cat) Move(newLocation string) (oldLocation string) {
cat.location, oldLocation = newLocation, cat.location
return
}
name string
age int
location string
}
func (cat Cat) Grow(){
fmt.Println("grow")
}
func (cat *Cat) Move(newLocation string) (oldLocation string) {
cat.location, oldLocation = newLocation, cat.location
return
}
2018-04-26
type Person struct {
Name string
Gender string
Age uint8
Address string
}
func (p *Person) Move(newAddress string) string {
oldAddress := p.Address
p.Address = newAddress
return oldAddress
}
Name string
Gender string
Age uint8
Address string
}
func (p *Person) Move(newAddress string) string {
oldAddress := p.Address
p.Address = newAddress
return oldAddress
}
2018-04-18
type Pet interface {
Name() string
Age() uint8
}
type Dog struct {
N string
A uint8
}
func (dog Dog) Name() (string){
return dog.N
}
func (dog Dog) Age() (uint8){
return dog.A
}
func main() {
}
Name() string
Age() uint8
}
type Dog struct {
N string
A uint8
}
func (dog Dog) Name() (string){
return dog.N
}
func (dog Dog) Age() (uint8){
return dog.A
}
func main() {
}
2018-04-18
package main
import "fmt"
func main() {
...
...
length := (2)
capacity := (4)
...
...
...
length = (7)
...
...
...
e2 := (0)
e3 := (8)
e4 := (11)
...
}
记得加前两行
import "fmt"
func main() {
...
...
length := (2)
capacity := (4)
...
...
...
length = (7)
...
...
...
e2 := (0)
e3 := (8)
e4 := (11)
...
}
记得加前两行
2018-04-17