type Widget struct {
id int
attrs []string
}
//下面两种传参有什么区别?
func doSomThing(ss *[]Widget){
}
func doOtherThing(sp []*widget){
}
type Widget struct {
id int
attrs []string
}
//下面两种传参有什么区别?
func doSomThing(ss *[]Widget){
}
func doOtherThing(sp []*widget){
}
type Widget struct {
id int
attrs []string
}
// type slicePtr *[]Widget
func doSomThing(ss *[]Widget){
// 循环
for _, s := range *ss {
}
}
// 普通的slice
func doOtherThing(ss []*widget){
// 循环
for _, s := range ss {
}
}
2 回答1.3k 阅读
2 回答1.1k 阅读
2 回答1.1k 阅读
2 回答855 阅读
3 回答674 阅读
997 阅读
1 回答776 阅读