Update 11.9.md (#654)

This commit is contained in:
marjune
2019-07-11 12:12:24 +08:00
committed by ᴊ. ᴄʜᴇɴ
parent f2b2bdf5db
commit 9f4478c668

View File

@@ -156,7 +156,7 @@ var interfaceSlice []interface{} = dataSlice
可惜不能这么做,编译时会出错:`cannot use dataSlice (type []myType) as type []interface { } in assignment`
原因是它们俩在内存中的布局是不一样的(参考 [官方说明](http://golang.org/doc/go_spec.html))。
原因是它们俩在内存中的布局是不一样的(参考 [Go wiki](https://github.com/golang/go/wiki/InterfaceSlice))。
必须使用 `for-range` 语句来一个一个显式地复制: