最贊回答 / 慕勒215309
chan的長度并不是指通道的字節(jié)數(shù),而是可以緩存的基本類型元素的個數(shù),ch2 := make(chan string, 1)是指通道ch2中可以保存一個字符串,而不論這個字符串有多長。
2018-05-07
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
簡單點的正確通關(guān)操作可以這樣
sum := (0)
for _, v := range numbers2 {
sum += v
}
sum := (0)
for _, v := range numbers2 {
sum += v
}
2018-04-19
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