slice5 获取长度6-4 = 2,即[5,6], 容量定义8, 8-4=4,即容量为4
slice5对容量进行扩充即数组为[5,6,7,8],容量和长度均为4, append后slice5变成了[5,6,7,8,11,12,13] 长度为7, 合并slice6 后为[0,0,0,8,11,12,13]
slice5对容量进行扩充即数组为[5,6,7,8],容量和长度均为4, append后slice5变成了[5,6,7,8,11,12,13] 长度为7, 合并slice6 后为[0,0,0,8,11,12,13]
2018-12-28
package main
import "fmt"
func main() {
ch4 := make(chan int, 1)
for i := 0; i < 4; i++ {
select {
case e, ok := <-ch4:
if !ok {
fmt.Println("End.")
return
}
fmt.Println(e)
default:
fmt.Println("No Data!")
ch4 <- 1
close(ch4)
}
}
}
import "fmt"
func main() {
ch4 := make(chan int, 1)
for i := 0; i < 4; i++ {
select {
case e, ok := <-ch4:
if !ok {
fmt.Println("End.")
return
}
fmt.Println(e)
default:
fmt.Println("No Data!")
ch4 <- 1
close(ch4)
}
}
}
2018-12-27
defer func(a int) {
fmt.Printf("%d ", fibonacci(a))
}
fmt.Printf("%d ", fibonacci(a))
}
2018-11-23