diff --git a/2.2.md b/2.2.md index 2a7df71b..bb8714ff 100644 --- a/2.2.md +++ b/2.2.md @@ -343,8 +343,8 @@ slice有一些简便的操作 - 长度,即`slice`的长度 - 最大长度,也就是`slice`开始位置到数组的最后位置的长度 - array := [10]byte {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'} - slice := A[4:8] + array := [10]byte {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j','k'} + slice := A[2:5] 上面代码的真正存储结构如下图所示 @@ -423,6 +423,22 @@ slice有一些简便的操作 ![](images/2.2.makenew.png?raw=true) +关于“零值”,所指并非是空值,而是一种“变量未填充前”的默认值。通常为 0。 +此处罗列 部分类型 的 “零值” + + int 0 + int8 0 + int32 0 + int64 0 + uint 0x0 + rune 0 //rune的实际类型是 int32 + byte 0x0 // byte的实际类型是 uint8 + float32 0 //长度为 4 byte + float64 0 //长度为 8 byte + bool false + string "" + + ## links diff --git a/images/2.2.makenew.png b/images/2.2.makenew.png index 8e74d672..11a9baa3 100644 Binary files a/images/2.2.makenew.png and b/images/2.2.makenew.png differ diff --git a/images/2.2.slice2.png b/images/2.2.slice2.png index f64d89f6..0729a1bf 100644 Binary files a/images/2.2.slice2.png and b/images/2.2.slice2.png differ