试图自学并发现很难找到例子,我的大脑已经陷入困境。非常不确定 3 和 4,需要帮助才能使 5 工作。
package main
import "fmt"
func main () {
println("0. Array:")
var a = [...]int{4,5,6,7,8,9} //assign
fmt.Println(a,"\n")
println("1. Slice:")
var as []int
as = a[:] //assign
fmt.Println(as,"\n")
println("2. Array of arrays:")
var b [4][len(a)]int
for i:= range b { //assign
b[i]=a
}
fmt.Println(b,"\n")
println("3. Array of slices:")
var d [len(b)][]int
for i:= range b { // assign
d[i] = b[i][:] //does this really work?
}
fmt.Println(d,"\n")
println("4. Slice of arrays:")
var c [][len(a)]int
c = b[:][:] // assign, does this really work?
fmt.Println(c,"\n")
println("5. Slice of slices:")
var e [][]int
// e = c // ???
fmt.Println(e,"\n")
}