type A stringtype B []stringfunc main() { one := "string" two := []string{"string"} var a A var b B b = two a = one // cannot use one (type string) as type A in assignment}
上面代码中,a=one 不正确很容易理解,以为A已经是一个新的类型了那 b=two 为什么没问题呢?如何去理解?
a=one
b=two
红糖糍粑
相关分类